rem
stringlengths 0
126k
| add
stringlengths 0
441k
| context
stringlengths 15
136k
|
---|---|---|
recordsToAdd.push(recordsToCopy[i]) | recordsToAdd.push(recordsToCopy[i]); | copyFrom : function(sourceKnownLayerStore, filterFunc) { this.removeAll(); var recordsToCopy = sourceKnownLayerStore.getRange(); if (filterFunc) { var recordsToAdd = []; for (var i = 0; i < recordsToCopy.length; i++) { var knownLayerRecord = new KnownLayerRecord(recordsToCopy[i]); if (!filterFunc(knownLayerRecord)) { continue; } recordsToAdd.push(recordsToCopy[i]) } this.add(recordsToAdd); } else { this.add(recordsToCopy); } }, |
mainWindow.keeFoxInst._KFLog.debug("4"); | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
mainWindow.keeFoxInst._KFLog.debug("5"); | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
mainWindow.keeFoxInst._KFLog.debug("6"); | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
mainWindow.keeFoxInst._KFLog.debug("7"); | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
mainWindow.keeFoxInst._KFLog.debug("8"); | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" | promptService.alert(mainWindow,"Something went wrong","Sorry, KeeFox could not automatically install the KeePassRPC" | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
+ " computer administrator for assistance."); | + " computer administrator for assistance."); return false; | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
return true; | function copyKeePassRPCFilesTo(keePassLocation){ var destFolder = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFolder.initWithPath(keePassLocation); destFolder.append("plugins"); var destFileKeePassRPC = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); destFileKeePassRPC.initWithPath(keePassLocation); destFileKeePassRPC.append("plugins"); destFileKeePassRPC.append("KeePassRPC.plgx"); try { if (!destFolder.exists()) destFolder.create(destFolder.DIRECTORY_TYPE, 0775); var KeePassRPCfile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); KeePassRPCfile.initWithPath(mainWindow.keeFoxInst._myDepsDir()); KeePassRPCfile.append("KeePassRPC.plgx"); if (destFileKeePassRPC.exists()) destFileKeePassRPC.remove(false); KeePassRPCfile.copyTo(destFolder,""); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } var KeePassRPCfound; var keePassRPCLocation; try { keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); } catch (ex) { mainWindow.keeFoxInst._KFLog.error(ex); } // if we can't find KeePassRPC, it was probably not copied because of // a permissions fault so lets try a fully escalated executable // to get it put into place if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("4"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); runKeePassRPCExecutableInstaller(keePassLocation); mainWindow.keeFoxInst._KFLog.debug("5"); keePassRPCLocation = "not installed"; keePassRPCLocation = mainWindow.keeFoxInst._discoverKeePassRPCInstallLocation(); // this also stores the preference mainWindow.keeFoxInst._KFLog.debug("6"); KeePassRPCfound = mainWindow.keeFoxInst._confirmKeePassRPCInstallLocation(keePassRPCLocation); mainWindow.keeFoxInst._KFLog.debug("7"); // still not found! Have to give up :-( if (!KeePassRPCfound) { mainWindow.keeFoxInst._KFLog.debug("8"); mainWindow.keeFoxInst._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert("Sorry, KeeFox could not automatically install the KeePassRPC" + " plugin for KeePass Password Safe 2, which is required for KeeFox to function." + " This is usually becuase you are trying to install to a location into which you are" + " not permitted to add new files. You may be able to restart Firefox and" + " try the installation again choosing different options or you could ask your" + " computer administrator for assistance."); } }} |
|
mainWindow.KFdownloadFile("IC5PriDownload", KF_KPZIP_DOWNLOAD_PATH + KF_KPZIP_FILE_NAME, KF_KPZIP_FILE_NAME, mainWindow, window); | persist = mainWindow.KFdownloadFile("IC5PriDownload", KF_KPZIP_DOWNLOAD_PATH + KF_KPZIP_FILE_NAME, KF_KPZIP_SAVE_NAME, mainWindow, window, persist); | function copyKPToSpecificLocationInstall() {//TODO: cancel KPsetup download // start the download if it hasn't already been done if (!(installState & KF_INSTALL_STATE_KPZIP_DOWNLOADING) && !(installState & KF_INSTALL_STATE_KPZIP_DOWNLOADED)) { installState |= KF_INSTALL_STATE_KPZIP_DOWNLOADING | KF_INSTALL_STATE_KI_DOWNLOADED; mainWindow.KFdownloadFile("IC5PriDownload", KF_KPZIP_DOWNLOAD_PATH + KF_KPZIP_FILE_NAME, KF_KPZIP_FILE_NAME, mainWindow, window); } hideInstallView(); showProgressView(); showSection('IC5zipKPdownloading'); // call this now and let it decide if it is the right time to run the installer or wait until it's called again by progress listener installState |= KF_INSTALL_STATE_SELECTED_TER; // mini-cheat: this state is also applied even when the true state is IC5 primary but this is the quick way to identify this varient of the installation IC5zipKP(mainWindow);} |
copyKeePassRPCFilesTo(keePassLocation); | if (!copyKeePassRPCFilesTo(keePassLocation)) { hideSection('IC3installing'); showSection('ERRORInstallButtonMain'); return; } | function copyKRPCToKnownKPLocationInstall(){ hideInstallView(); keePassLocation = mainWindow.keeFoxInst._keeFoxExtension.prefs .getValue("keePassInstalledLocation", "not installed"); if (keePassLocation == "not installed") { mainWindow.keeFoxInst._KFLog.error("We seem to have forgetton where KeePass is installed!"); showSection('ERRORInstallButtonMain'); } else { showProgressView(); showSection('IC3installing'); copyKeePassRPCFilesTo(keePassLocation); hideSection('IC3installing'); showSection('InstallFinished'); mainWindow.keeFoxInst._KFLog.debug("AAA"); launchAndConnectToKeePass(); }} |
mainWindow.keeFoxInst._KFLog.debug("AAA"); | function copyKRPCToKnownKPLocationInstall(){ hideInstallView(); keePassLocation = mainWindow.keeFoxInst._keeFoxExtension.prefs .getValue("keePassInstalledLocation", "not installed"); if (keePassLocation == "not installed") { mainWindow.keeFoxInst._KFLog.error("We seem to have forgetton where KeePass is installed!"); showSection('ERRORInstallButtonMain'); } else { showProgressView(); showSection('IC3installing'); copyKeePassRPCFilesTo(keePassLocation); hideSection('IC3installing'); showSection('InstallFinished'); mainWindow.keeFoxInst._KFLog.debug("AAA"); launchAndConnectToKeePass(); }} |
|
},getParent:function(){var h=this.$.parentNode;return h&&h.nodeType==1?new d.node(h):null;},getParents:function(h){var i=this,j=[];do j[h?'push':'unshift'](i);while(i=i.getParent())return j;},getCommonAncestor:function(h){var j=this;if(h.equals(j))return j;if(h.contains&&h.contains(j))return h;var i=j.contains?j:j.getParent();do{if(i.contains(h))return i;}while(i=i.getParent())return null;},getPosition:function(h){var i=this.$,j=h.$;if(i.compareDocumentPosition)return i.compareDocumentPosition(j);if(i==j)return 0;if(this.type==1&&h.type==1){if(i.contains){if(i.contains(j))return 16+4;if(j.contains(i))return 8+2;}if('sourceIndex' in i)return i.sourceIndex<0||j.sourceIndex<0?1:i.sourceIndex<j.sourceIndex?4:2;}var k=this.getAddress(),l=h.getAddress(),m=Math.min(k.length,l.length);for(var n=0;n<=m-1;n++){if(k[n]!=l[n]){if(n<m)return k[n]<l[n]?4:2;break;}}return k.length<l.length?16+4:8+2;},getAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return new d.node(j);j=j.parentNode;}return null;},hasAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return true;j=j.parentNode;}return false;},move:function(h,i){h.append(this.remove(),i);},remove:function(h){var i=this.$,j=i.parentNode;if(j){if(h)for(var k;k=i.firstChild;)j.insertBefore(i.removeChild(k),i);j.removeChild(i);}return this;},replace:function(h){this.insertBefore(h);h.remove();},trim:function(){this.ltrim();this.rtrim();},ltrim:function(){var k=this;var h;while(k.getFirst&&(h=k.getFirst())){if(h.type==3){var i=e.ltrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(j-i.length);k.$.removeChild(k.$.firstChild);}}break;}},rtrim:function(){var k=this;var h;while(k.getLast&&(h=k.getLast())){if(h.type==3){var i=e.rtrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(i.length);k.$.lastChild.parentNode.removeChild(k.$.lastChild);}}break;}if(!c&&!b.opera){h=k.$.lastChild;if(h&&h.type==1&&h.nodeName.toLowerCase()=='br')h.parentNode.removeChild(h);}}});d.nodeList=function(h){this.$=h;};d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j); | };d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j);k.setHtml(i);return k.getFirst().remove();};h.setMarker=function(i,j,k,l){var m=j.getCustomData('list_marker_id')||j.setCustomData('list_marker_id',e.getNextNumber()).getCustomData('list_marker_id'),n=j.getCustomData('list_marker_names')||j.setCustomData('list_marker_names',{}).getCustomData('list_marker_names');i[m]=j;n[k]=1;return j.setCustomData(k,l);};h.clearAllMarkers=function(i){for(var j in i)h.clearMarkers(i,i[j],true);};h.clearMarkers=function(i,j,k){var l=j.getCustomData('list_marker_names'),m=j.getCustomData('list_marker_id');for(var n in l)j.removeCustomData(n);j.removeCustomData('list_marker_names');if(k){j.removeCustomData('list_marker_id');delete i[m];}};e.extend(h.prototype,{type:1,addClass:function(i){var j=this.$.className;if(j){var k=new RegExp('(?:^|\\s)'+i+'(?:\\s|$)','');if(!k.test(j))j+=' '+i;}this.$.className=j||i;},removeClass:function(i){var j=this.getAttribute('class');if(j){var k=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','i');if(k.test(j)){j=j.replace(k,'').replace(/^\s+/,'');if(j)this.setAttribute('class',j);else this.removeAttribute('class');}}},hasClass:function(i){var j=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','');return j.test(this.getAttribute('class'));},append:function(i,j){var k=this;if(typeof i=='string')i=k.getDocument().createElement(i);if(j)k.$.insertBefore(i.$,k.$.firstChild);else k.$.appendChild(i.$);return i;},appendHtml:function(i){var k=this;if(!k.$.childNodes.length)k.setHtml(i);else{var j=new h('div',k.getDocument());j.setHtml(i);j.moveChildren(k);}},appendText:function(i){if(this.$.text!=undefined)this.$.text+=i;else this.append(new d.text(i));},appendBogus:function(){var k=this;var i=k.getLast();while(i&&i.type==3&&!e.rtrim(i.getText()))i=i.getPrevious();if(!i||!i.is||!i.is('br')){var j=b.opera?k.getDocument().createText(''):k.getDocument().createElement('br');b.gecko&&j.setAttribute('type','_moz');k.append(j);}},breakParent:function(i){var l=this;var j=new d.range(l.getDocument());j.setStartAfter(l);j.setEndAfter(i);var k=j.extractContents();j.insertNode(l.remove());k.insertAfterNode(l);},contains:c||b.webkit?function(i){var j=this.$;return i.type!=1?j.contains(i.getParent().$):j!=i.$&&j.contains(i.$); | },getParent:function(){var h=this.$.parentNode;return h&&h.nodeType==1?new d.node(h):null;},getParents:function(h){var i=this,j=[];do j[h?'push':'unshift'](i);while(i=i.getParent())return j;},getCommonAncestor:function(h){var j=this;if(h.equals(j))return j;if(h.contains&&h.contains(j))return h;var i=j.contains?j:j.getParent();do{if(i.contains(h))return i;}while(i=i.getParent())return null;},getPosition:function(h){var i=this.$,j=h.$;if(i.compareDocumentPosition)return i.compareDocumentPosition(j);if(i==j)return 0;if(this.type==1&&h.type==1){if(i.contains){if(i.contains(j))return 16+4;if(j.contains(i))return 8+2;}if('sourceIndex' in i)return i.sourceIndex<0||j.sourceIndex<0?1:i.sourceIndex<j.sourceIndex?4:2;}var k=this.getAddress(),l=h.getAddress(),m=Math.min(k.length,l.length);for(var n=0;n<=m-1;n++){if(k[n]!=l[n]){if(n<m)return k[n]<l[n]?4:2;break;}}return k.length<l.length?16+4:8+2;},getAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return new d.node(j);j=j.parentNode;}return null;},hasAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return true;j=j.parentNode;}return false;},move:function(h,i){h.append(this.remove(),i);},remove:function(h){var i=this.$,j=i.parentNode;if(j){if(h)for(var k;k=i.firstChild;)j.insertBefore(i.removeChild(k),i);j.removeChild(i);}return this;},replace:function(h){this.insertBefore(h);h.remove();},trim:function(){this.ltrim();this.rtrim();},ltrim:function(){var k=this;var h;while(k.getFirst&&(h=k.getFirst())){if(h.type==3){var i=e.ltrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(j-i.length);k.$.removeChild(k.$.firstChild);}}break;}},rtrim:function(){var k=this;var h;while(k.getLast&&(h=k.getLast())){if(h.type==3){var i=e.rtrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(i.length);k.$.lastChild.parentNode.removeChild(k.$.lastChild);}}break;}if(!c&&!b.opera){h=k.$.lastChild;if(h&&h.type==1&&h.nodeName.toLowerCase()=='br')h.parentNode.removeChild(h);}}});d.nodeList=function(h){this.$=h;};d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j); |
for (var i = 0; i < countryId.length; i++) { | countryStateList: function(){ var populateStates = function(statesCombo, countries){ var statesC = $(statesCombo), statesCache = VMCache.get('states'), statesGroup = [], states2add = ''; statesCombo.$countries = statesCombo.$countries ? statesCombo.$countries : []; for(var i = 0, n = statesCombo.$countries.length; i < n; i++){ if( VM.inArray( countries, statesCombo.$countries[i]) === undefined ){ for( var state in statesCache[ statesCombo.$countries[i] ] ){ statesC.find('[value='+ statesCache[ statesCombo.$countries[i] ][state].state_id +']').remove(); } } } for(var i = 0, n = countries.length; i < n; i++){ if( VM.inArray( statesCombo.$countries, countries[i]) === undefined ){ statesGroup = statesCache[ countries[i] ]; for(var j in statesGroup){ if(statesGroup[j].state_id){ states2add += '<option value="'+ statesGroup[j].state_id +'">'+ statesGroup[j].state_name +'</option>'; } } } } statesCombo.$countries = countries; statesC.append( states2add ).removeAttr('disabled'); }; $( VMConfig.get('dependentSelector') ).each(function(){ var params = VMConfig.get('dependentExpr').exec( this.className ), //parse parent id that = this; this.className = this.className || ''; if( params && params[1]){ $('#'+ params[1]).change(function(){ var countries = $(this).val(), statesCache = VMCache.get('states'), //shortchut to [[this]] and scope solution country = 0, countriesSend = [], cStack = []; for (var i = 0; i < countryId.length; i++) { countries = countries.push ? countries : [countries]; $(that).attr('disabled', 'disabled'); for(var i = 0, n = countries.length; i < n; i++){ country = countries[i]; //use cache solution to speed up the process if( statesCache[country] ){ cStack.push( country ); } else{ countriesSend.push(country); } } if( countriesSend.length ){ $.ajax({ url: VMConfig.get('countryStateURL') + countriesSend.toString(), dataType: 'json', success: function(states){ for(var country in states){ cStack.push( country ); VMCache.add('states', states[country], country); } populateStates( that, cStack ); return true; } }); } else{ populateStates( that, cStack ); } }); } }); return this; }, add: function(props){ if(props.constructor === Object){ for(var i in props){ this[i] = props[i]; } } return this; } }; })(jQuery); |
|
add: function(props){ if(props.constructor === Object){ for(var i in props){ this[i] = props[i]; } } return this; } }; })(jQuery); | countryStateList: function(){ var populateStates = function(statesCombo, countries){ var statesC = $(statesCombo), statesCache = VMCache.get('states'), statesGroup = [], states2add = ''; statesCombo.$countries = statesCombo.$countries ? statesCombo.$countries : []; for(var i = 0, n = statesCombo.$countries.length; i < n; i++){ if( VM.inArray( countries, statesCombo.$countries[i]) === undefined ){ for( var state in statesCache[ statesCombo.$countries[i] ] ){ statesC.find('[value='+ statesCache[ statesCombo.$countries[i] ][state].state_id +']').remove(); } } } for(var i = 0, n = countries.length; i < n; i++){ if( VM.inArray( statesCombo.$countries, countries[i]) === undefined ){ statesGroup = statesCache[ countries[i] ]; for(var j in statesGroup){ if(statesGroup[j].state_id){ states2add += '<option value="'+ statesGroup[j].state_id +'">'+ statesGroup[j].state_name +'</option>'; } } } } statesCombo.$countries = countries; statesC.append( states2add ).removeAttr('disabled'); }; $( VMConfig.get('dependentSelector') ).each(function(){ var params = VMConfig.get('dependentExpr').exec( this.className ), //parse parent id that = this; this.className = this.className || ''; if( params && params[1]){ $('#'+ params[1]).change(function(){ var countries = $(this).val(), statesCache = VMCache.get('states'), //shortchut to [[this]] and scope solution country = 0, countriesSend = [], cStack = []; for (var i = 0; i < countryId.length; i++) { countries = countries.push ? countries : [countries]; $(that).attr('disabled', 'disabled'); for(var i = 0, n = countries.length; i < n; i++){ country = countries[i]; //use cache solution to speed up the process if( statesCache[country] ){ cStack.push( country ); } else{ countriesSend.push(country); } } if( countriesSend.length ){ $.ajax({ url: VMConfig.get('countryStateURL') + countriesSend.toString(), dataType: 'json', success: function(states){ for(var country in states){ cStack.push( country ); VMCache.add('states', states[country], country); } populateStates( that, cStack ); return true; } }); } else{ populateStates( that, cStack ); } }); } }); return this; }, add: function(props){ if(props.constructor === Object){ for(var i in props){ this[i] = props[i]; } } return this; } }; })(jQuery); |
|
if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); | var root = false; if(ref_node == -1) { root = true; ref_node = this.container; } else ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(!root && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); var pos = position; var tmp = ref_node; if(position == "before") { position = ref_node.parent().children().index(ref_node); ref_node = ref_node.parents("li:eq(0)"); } if(position == "after") { position = ref_node.parent().children().index(ref_node) + 1; ref_node = ref_node.parents("li:eq(0)"); } if(!root && ref_node.size() == 0) { root = true; ref_node = this.container; } if(!root) { if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); if(ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else this.open_branch(ref_node, true); | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
else { this.open_branch(ref_node, true); } | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
|
switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
|
if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; | if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(tmp) || "default"; | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) | max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", (root ? -1 : ref_node) ) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", (root ? -1 : ref_node) ) : -1, valid_children : this.check("valid_children", (root ? -1 : ref_node) ) | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
while(t !== -1) { | while(t !== -1 && !root) { | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); | if((typeof position).toLowerCase() == "undefined" || position == "inside") position = (this.settings.rules.createat == "top") ? 0 : ref_node.children("ul:eq(0)").children("li").size(); if(ref_node.children("ul").size() == 0 || (root == true && ref_node.children("ul").children("li").size() == 0) ) { if(!root) var a = this.moved($li,ref_node.children("a:eq(0)"),"inside", true); else var a = this.moved($li,this.container.children("ul:eq(0)"),"inside", true); } else if(pos == "before" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true); else if(pos == "after" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size()) var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after", true); else if(ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true); else var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true); | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); | if(a === false) return this.error("CREATE: ABORTED"); | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); | if(torename) { this.select_branch($li.children("a:eq(0)")); this.rename(); } | create : function (obj, ref_node, position) { if(this.locked) return this.error("LOCKED"); if(ref_node != -1) ref_node = ref_node ? this.get_node(ref_node) : this.selected; if(ref_node != -1 && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); if(typeof position == "undefined") position = "inside"; if(ref_node != -1 && position != "after" && position != "before" && ref_node.hasClass("closed")) { if(this.settings.data.async && ref_node.children("ul").size() == 0) { var _this = this; return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); } else { this.open_branch(ref_node, true); } } switch(position) { case "before": position = ref_node.parent().children().index(ref_node); ref_node = this.parent(ref_node); break; case "after": position = ref_node.parent().children().index(ref_node) + 1; ref_node = this.parent(ref_node); break; case "inside": position = (this.settings.rules.createat == "top") ? 0 : this.children(ref_node).size(); break; default: break; } if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); var torename = false; if(!obj) obj = {}; else obj = $.extend(true, {}, obj); if(!obj.attributes) obj.attributes = {}; if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(ref_node) || "default"; if(this.settings.languages.length) { if(!obj.data) { obj.data = {}; torename = true; } for(var i = 0; i < this.settings.languages.length; i++) { if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; } } else { if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } } // parse data obj = this.callback("ondata",[obj, this]); var obj_s = $.tree.datastores.json().parse(obj,this); obj_s = this.callback("onparse", [obj_s, this]); var $li = $(obj_s); var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", ref_node) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", ref_node) : -1, valid_children : this.check("valid_children", ref_node) }; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED"); } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = ref_node; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; var t = $li; while(t.size() > 0) { if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } if(!this.callback("beforecreate", [{ 'node' : $li.get(0), 'parent' : ref_node == -1 ? -1 : ref_node.get(0), 'position' : position }])) return this.error("CREATE: STOPPED"); // Rollback var rb = {}; rb[this.container.attr("id")] = this.get_rollback(); $li = this._create($li, ref_node, position, true); this.select_branch($li.children("a:eq(0)")); this.rename(false, true, rb); return $li; }, |
if (onchange && typeof onchange != "function") { | if (onchange && typeof onchange == "function") { | function create_get_set(cur_val, onchange) { return {get: function () { return cur_val; }, set: function (new_val) { /// Temporarily store the original value to be sent to the onchange function. var old_val = cur_val; cur_val = new_val; /// Optionally run a function when the value is changed. if (onchange && typeof onchange != "function") { window.setTimeout(function () { onchange({old_val: old_val, new_val: new_val}); }, 0); } }}; } |
var $tpl = ''; $tpl += '<li class="ui-widget graph-image '+timespan+'">'; $tpl += '<ul class="sortable ui-sortable">'; for ( var g = 0; g < graphs.length; g++) { $tpl += '<li class="gc">'; $tpl += get_graph_menu(); if ($('#graph-caching-checkbox').attr('checked')) { $tpl += '<img class="gc-img" src="media/images/graph-load.png" title="' + graphs[g] + '"/></li>'; } else { $tpl += '<img class="gc-img" src="' + graphs[g] + '"/></li>'; } $tpl += '</li>'; } $tpl += '</ul>'; $tpl += '</li>'; $('.graph-imgs-container').append($tpl); | var $tpl = ''; $tpl += '<li class="ui-widget graph-image '+timespan+'">'; $tpl += '<ul class="sortable ui-sortable">'; for ( var g = 0; g < graphs.length; g++) { $tpl += '<li class="gc">'; $tpl += get_graph_menu(); if ($('#graph-caching-checkbox').attr('checked')) { $tpl += '<img class="gc-img toload" src="media/images/graph-load.png" title="' + graphs[g] + '"/></li>'; } else { $tpl += '<img class="gc-img" src="' + graphs[g] + '"/></li>'; } $tpl += '</li>'; } $tpl += '</ul>'; $tpl += '</li>'; $('.graph-imgs-container').append($tpl); | function create_graph_list(timespan, graphs) { var $tpl = ''; $tpl += '<li class="ui-widget graph-image '+timespan+'">'; $tpl += '<ul class="sortable ui-sortable">'; for ( var g = 0; g < graphs.length; g++) { $tpl += '<li class="gc">'; $tpl += get_graph_menu(); if ($('#graph-caching-checkbox').attr('checked')) { $tpl += '<img class="gc-img" src="media/images/graph-load.png" title="' + graphs[g] + '"/></li>'; } else { $tpl += '<img class="gc-img" src="' + graphs[g] + '"/></li>'; } $tpl += '</li>'; } $tpl += '</ul>'; $tpl += '</li>'; $('.graph-imgs-container').append($tpl);} |
},isArray:function(f){return!!f&&f instanceof Array;},isEmpty:function(f){for(var g in f){if(f.hasOwnProperty(g))return false;}return true;},cssStyleToDomStyle:(function(){var f=document.createElement('div').style,g=typeof f.cssFloat!='undefined'?'cssFloat':typeof f.styleFloat!='undefined'?'styleFloat':'float';return function(h){if(h=='float')return g;else return h.replace(/-./g,function(i){return i.substr(1).toUpperCase();});};})(),buildStyleHtml:function(f){f=[].concat(f);var g,h=[];for(var i=0;i<f.length;i++){g=f[i];if(/@import|[{}]/.test(g))h.push('<style>'+g+'</style>');else h.push('<link type="text/css" rel=stylesheet href="'+g+'">');}return h.join('');},htmlEncode:function(f){var g=function(k){var l=new d.element('span');l.setText(k);return l.getHtml();},h=g('\n').toLowerCase()=='<br>'?function(k){return g(k).replace(/<br>/gi,'\n');}:g,i=g('>')=='>'?function(k){return h(k).replace(/>/g,'>');}:h,j=g(' ')==' '?function(k){return i(k).replace(/ /g,' ');}:i;this.htmlEncode=j;return this.htmlEncode(f);},htmlEncodeAttr:function(f){return f.replace(/"/g,'"').replace(/</g,'<').replace(/>/,'>');},escapeCssSelector:function(f){return f.replace(/[\s#:.,$*^\[\]()~=+>]/g,'\\$&');},getNextNumber:(function(){var f=0;return function(){return++f;};})(),override:function(f,g){return g(f);},setTimeout:function(f,g,h,i,j){if(!j)j=window;if(!h)h=j;return j.setTimeout(function(){if(i)f.apply(h,[].concat(i));else f.apply(h);},g||0);},trim:(function(){var f=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(g){return g.replace(f,'');};})(),ltrim:(function(){var f=/^[ \t\n\r]+/g;return function(g){return g.replace(f,'');};})(),rtrim:(function(){var f=/[ \t\n\r]+$/g;return function(g){return g.replace(f,'');};})(),indexOf:Array.prototype.indexOf?function(f,g){return f.indexOf(g);}:function(f,g){for(var h=0,i=f.length;h<i;h++){if(f[h]===g)return h;}return-1;},bind:function(f,g){return function(){return f.apply(g,arguments);};},createClass:function(f){var g=f.$,h=f.base,i=f.privates||f._,j=f.proto,k=f.statics;if(i){var l=g;g=function(){var p=this;var m=p._||(p._={});for(var n in i){var o=i[n];m[n]=typeof o=='function'?a.tools.bind(o,p):o;}l.apply(p,arguments);};}if(h){g.prototype=this.prototypedCopy(h.prototype);g.prototype['constructor']=g;g.prototype.base=function(){this.base=h.prototype.base;h.apply(this,arguments);this.base=arguments.callee;};}if(j)this.extend(g.prototype,j,true);if(k)this.extend(g,k,true);return g;},addFunction:function(f,g){return e.push(function(){f.apply(g||this,arguments); | g.prototype=f;return new g();},isArray:function(f){return!!f&&f instanceof Array;},isEmpty:function(f){for(var g in f){if(f.hasOwnProperty(g))return false;}return true;},cssStyleToDomStyle:(function(){var f=document.createElement('div').style,g=typeof f.cssFloat!='undefined'?'cssFloat':typeof f.styleFloat!='undefined'?'styleFloat':'float';return function(h){if(h=='float')return g;else return h.replace(/-./g,function(i){return i.substr(1).toUpperCase();});};})(),buildStyleHtml:function(f){f=[].concat(f);var g,h=[];for(var i=0;i<f.length;i++){g=f[i];if(/@import|[{}]/.test(g))h.push('<style>'+g+'</style>');else h.push('<link type="text/css" rel=stylesheet href="'+g+'">');}return h.join('');},htmlEncode:function(f){var g=function(k){var l=new d.element('span');l.setText(k);return l.getHtml();},h=g('\n').toLowerCase()=='<br>'?function(k){return g(k).replace(/<br>/gi,'\n');}:g,i=g('>')=='>'?function(k){return h(k).replace(/>/g,'>');}:h,j=g(' ')==' '?function(k){return i(k).replace(/ /g,' ');}:i;this.htmlEncode=j;return this.htmlEncode(f);},htmlEncodeAttr:function(f){return f.replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>');},escapeCssSelector:function(f){return f.replace(/[\s#:.,$*^\[\]()~=+>]/g,'\\$&');},getNextNumber:(function(){var f=0;return function(){return++f;};})(),getNextId:function(){return 'cke_'+this.getNextNumber();},override:function(f,g){return g(f);},setTimeout:function(f,g,h,i,j){if(!j)j=window;if(!h)h=j;return j.setTimeout(function(){if(i)f.apply(h,[].concat(i));else f.apply(h);},g||0);},trim:(function(){var f=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(g){return g.replace(f,'');};})(),ltrim:(function(){var f=/^[ \t\n\r]+/g;return function(g){return g.replace(f,'');};})(),rtrim:(function(){var f=/[ \t\n\r]+$/g;return function(g){return g.replace(f,'');};})(),indexOf:Array.prototype.indexOf?function(f,g){return f.indexOf(g);}:function(f,g){for(var h=0,i=f.length;h<i;h++){if(f[h]===g)return h;}return-1;},bind:function(f,g){return function(){return f.apply(g,arguments);};},createClass:function(f){var g=f.$,h=f.base,i=f.privates||f._,j=f.proto,k=f.statics;if(i){var l=g;g=function(){var p=this;var m=p._||(p._={});for(var n in i){var o=i[n];m[n]=typeof o=='function'?a.tools.bind(o,p):o;}l.apply(p,arguments);};}if(h){g.prototype=this.prototypedCopy(h.prototype);g.prototype['constructor']=g;g.prototype.base=function(){this.base=h.prototype.base;h.apply(this,arguments);this.base=arguments.callee;};}if(j)this.extend(g.prototype,j,true); if(k)this.extend(g,k,true);return g;},addFunction:function(f,g){return e.push(function(){f.apply(g||this,arguments);})-1;},removeFunction:function(f){e[f]=null;},callFunction:function(f){var g=e[f];return g&&g.apply(window,Array.prototype.slice.call(arguments,1));},cssLength:(function(){var f=/^\d+(?:\.\d+)?$/;return function(g){return g+(f.test(g)?'px':'');};})(),repeat:function(f,g){return new Array(g+1).join(f);},tryThese:function(){var f;for(var g=0,h=arguments.length;g<h;g++){var i=arguments[g];try{f=i();break;}catch(j){}}return f;},genKey:function(){return Array.prototype.slice.call(arguments).join('-');}};})();var e=a.tools;a.dtd=(function(){var f=e.extend,g={isindex:1,fieldset:1},h={input:1,button:1,select:1,textarea:1,label:1},i=f({a:1},h),j=f({iframe:1},i),k={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},l={ins:1,del:1,script:1,style:1},m=f({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},l),n=f({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},m),o=f({p:1},n),p=f({iframe:1},n,h),q={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},r=f({a:1},p),s={tr:1},t={'#':1},u=f({param:1},q),v=f({form:1},g,j,k,o),w={li:1},x={style:1,script:1},y={base:1,link:1,meta:1,title:1},z=f(y,x),A={head:1,body:1},B={html:1},C={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:f(B,A,y),$block:C,$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:r,$body:f({script:1,style:1},C),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:A,head:z,style:t,script:t,body:v,base:{},link:{},meta:{},title:t,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:v,td:v,br:{},th:v,center:v,kbd:r,button:f(o,k),basefont:{},h5:r,h4:r,samp:r,h6:r,ol:w,h1:r,h3:r,option:t,h2:r,form:f(g,j,k,o),select:{optgroup:1,option:1},font:r,ins:r,menu:w,abbr:r,label:r,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:r,script:t,tfoot:s,cite:r,li:v,input:{},iframe:v,strong:r,textarea:t,noframes:v,big:r,small:r,span:r,hr:{},dt:r,sub:r,optgroup:{option:1},param:{},bdo:r,'var':r,div:v,object:u,sup:r,dd:v,strike:r,area:{},dir:w,map:f({area:1,form:1,p:1},g,l,k),applet:u,dl:{dt:1,dd:1},del:r,isindex:{},fieldset:f({legend:1},q),thead:s,ul:w,acronym:r,b:r,a:p,blockquote:v,caption:r,i:r,u:r,tbody:s,s:r,address:f(j,o),tt:r,legend:r,q:r,pre:f(m,i),p:r,em:r,dfn:r}; | },isArray:function(f){return!!f&&f instanceof Array;},isEmpty:function(f){for(var g in f){if(f.hasOwnProperty(g))return false;}return true;},cssStyleToDomStyle:(function(){var f=document.createElement('div').style,g=typeof f.cssFloat!='undefined'?'cssFloat':typeof f.styleFloat!='undefined'?'styleFloat':'float';return function(h){if(h=='float')return g;else return h.replace(/-./g,function(i){return i.substr(1).toUpperCase();});};})(),buildStyleHtml:function(f){f=[].concat(f);var g,h=[];for(var i=0;i<f.length;i++){g=f[i];if(/@import|[{}]/.test(g))h.push('<style>'+g+'</style>');else h.push('<link type="text/css" rel=stylesheet href="'+g+'">');}return h.join('');},htmlEncode:function(f){var g=function(k){var l=new d.element('span');l.setText(k);return l.getHtml();},h=g('\n').toLowerCase()=='<br>'?function(k){return g(k).replace(/<br>/gi,'\n');}:g,i=g('>')=='>'?function(k){return h(k).replace(/>/g,'>');}:h,j=g(' ')==' '?function(k){return i(k).replace(/ /g,' ');}:i;this.htmlEncode=j;return this.htmlEncode(f);},htmlEncodeAttr:function(f){return f.replace(/"/g,'"').replace(/</g,'<').replace(/>/,'>');},escapeCssSelector:function(f){return f.replace(/[\s#:.,$*^\[\]()~=+>]/g,'\\$&');},getNextNumber:(function(){var f=0;return function(){return++f;};})(),override:function(f,g){return g(f);},setTimeout:function(f,g,h,i,j){if(!j)j=window;if(!h)h=j;return j.setTimeout(function(){if(i)f.apply(h,[].concat(i));else f.apply(h);},g||0);},trim:(function(){var f=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(g){return g.replace(f,'');};})(),ltrim:(function(){var f=/^[ \t\n\r]+/g;return function(g){return g.replace(f,'');};})(),rtrim:(function(){var f=/[ \t\n\r]+$/g;return function(g){return g.replace(f,'');};})(),indexOf:Array.prototype.indexOf?function(f,g){return f.indexOf(g);}:function(f,g){for(var h=0,i=f.length;h<i;h++){if(f[h]===g)return h;}return-1;},bind:function(f,g){return function(){return f.apply(g,arguments);};},createClass:function(f){var g=f.$,h=f.base,i=f.privates||f._,j=f.proto,k=f.statics;if(i){var l=g;g=function(){var p=this;var m=p._||(p._={});for(var n in i){var o=i[n];m[n]=typeof o=='function'?a.tools.bind(o,p):o;}l.apply(p,arguments);};}if(h){g.prototype=this.prototypedCopy(h.prototype);g.prototype['constructor']=g;g.prototype.base=function(){this.base=h.prototype.base;h.apply(this,arguments);this.base=arguments.callee;};}if(j)this.extend(g.prototype,j,true);if(k)this.extend(g,k,true);return g;},addFunction:function(f,g){return e.push(function(){f.apply(g||this,arguments); |
featurePrefix: null, | featurePrefix: null | function createClusteredWFSLayer(layerDef) { var title = layerDef.Title; var options = layerDef.Options; var wfs_url = layerDef.Url; var delimiter = '?'; if (options['map'] != null) { wfs_url = layerDef.Url+delimiter+"map="+options['map']; delimiter = '&'; } var featureType = layerDef.ogc_name; var p = new OpenLayers.Protocol.WFS({ url: wfs_url, featureType: featureType, featurePrefix: null, }); // store the url into a separate parameter to have a backup in case we // need to change the url (i.e for the species picklist). p.wfs_url = wfs_url + delimiter; p.format.setNamespace("feature", "http://mapserver.gis.umn.edu/mapserver"); var strategyCluster = new OpenLayers.Strategy.Cluster(); strategyCluster.distance = 25; strategies = [ new OpenLayers.Strategy.Fixed(), strategyCluster ]; layer = new OpenLayers.Layer.Vector(title, { strategies: strategies, protocol: p }); return layer;} |
var wfs_url = layerDef.Url+"?map="+options['map']; | var wfs_url = layerDef.Url; | function createClusteredWFSLayer(layerDef) { var title = layerDef.Title; var options = layerDef.Options; var wfs_url = layerDef.Url+"?map="+options['map']; var featureType = layerDef.ogc_name; var p = new OpenLayers.Protocol.WFS({ url: wfs_url, featureType: featureType, featurePrefix: null }); p.format.setNamespace("feature", "http://mapserver.gis.umn.edu/mapserver"); var strategyCluster = new OpenLayers.Strategy.Cluster(); strategyCluster.distance = 25; strategies = [ new OpenLayers.Strategy.Fixed(), strategyCluster ]; layer = new OpenLayers.Layer.Vector(title, { strategies: strategies, protocol: p }); return layer;} |
var wfs_url = layerDef.Url; | var wfs_url = layerDef.Url+"?map="+options['map']; | function createClusteredWFSLayer(layerDef) { var title = layerDef.Title; var options = layerDef.Options; var wfs_url = layerDef.Url; var featureType = layerDef.ogc_name; var p = new OpenLayers.Protocol.WFS({ url: wfs_url, featureType: featureType, featurePrefix: null }); p.format.setNamespace("feature", "http://mapserver.gis.umn.edu/mapserver"); var strategyCluster = new OpenLayers.Strategy.Cluster(); strategyCluster.distance = 25; strategies = [ new OpenLayers.Strategy.Fixed(), strategyCluster ]; layer = new OpenLayers.Layer.Vector(title, { strategies: strategies, protocol: p }); return layer;} |
if(editing) return; editing = true; | function createElement() { // grab current value options.current.value = element.html(); // grab extra params if($(this).parent().attr('rel') != '') options.current.extraParams = eval('('+ $(this).parent().attr('rel') +')'); // add class element.addClass('inlineEditing'); // remove events element.unbind('click').unbind('focus'); // set html element.html('<input type="text" class="'+ options.inputClasses +'" value="'+ options.current.value +'" />'); // store element options.current.element = $(element.find('input')[0]); // set focus options.current.element.select(); // bind events options.current.element.bind('blur', saveElement); options.current.element.keyup(function(evt) { // handle escape if(evt.which == 27) { // reset options.current.element.val(options.current.value); // destroy destroyElement(); } // save when someone presses enter if(evt.which == 13) saveElement(); }); } |
|
" g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=A(n,"width","300px");g.style.height=A(n,"height","24px");n.parentNode.replaceChild(g,n);var q=(n.getAttribute("preload")||"").toLowerCase(),i=[];x&&i.push({url:C(x)});if(G)i.push({url:C(G),autoPlay:y(n,"autoplay"),autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(q==""||q=="auto"),onBeforeFinish:function(){return!y(n,"loop")}});x={controls:u&&{url:C(t.flowplayerControlsSwf),fullscreen:false,autoHide:j==p&&"always"|| "never"}||null};if(E(I)==E(f)){x.audio={url:C(t.flowplayerAudioSwf)};u||(x.controls={url:C(t.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}u={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:x};t.configureFlowplayer(j,n,u);flowplayer(g,{src:C(t.flowplayerSwf),wmode:"opaque"},u)};if(z.jQuery)jQuery(t);else z.DomReady&&DomReady.ready(t);z.html5media=t})(this,document); | t.MP3_FORMAT],k=t.fileExtensions={video:{ogg:a,ogv:a,avi:b,mp4:b,mkv:b,h264:b,"264":b,avc:b,m4v:b,"3gp":b,"3gpp":b,"3g2":b,mpg:b,mpeg:b},audio:{ogg:c,oga:c,aac:m,m4a:m,mp3:f,wav:l}},r=z.location.protocol+" "",G;if(H)G=B(j,H);else v(n.getElementsByTagName("source"),function(s){var D=s.getAttribute("src");D&&!H&&v(h,function(I){G=B(j,D,s.getAttribute("type"));if(E(G)==E(I))H=D})});var g=o.createElement("span");g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=A(n,"width","300px");g.style.height=A(n,"height","24px");n.parentNode.replaceChild(g,n);var q=(n.getAttribute("preload")||"").toLowerCase(),i=[];x&&i.push({url:C(x)});if(H)i.push({url:C(H),autoPlay:y(n,"autoplay"), autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(q==""||q=="auto"),onBeforeFinish:function(){return!y(n,"loop")}});x={controls:u&&{url:C(t.flowplayerControlsSwf),fullscreen:false,autoHide:j==p&&"always"||"never"}||null};if(E(G)==E(f)){x.audio={url:C(t.flowplayerAudioSwf)};u||(x.controls={url:C(t.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}u={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:x};t.configureFlowplayer(j,n,u);flowplayer(g,{src:C(t.flowplayerSwf), wmode:"opaque"},u)};if(z.jQuery)jQuery(t);else z.DomReady&&DomReady.ready(t);z.html5media=t})(this,document); | "//"+z.location.host,w=String(z.location);v(o.getElementsByTagName("base"),function(j){if(j.href)w=j.href});w=w.split("/").slice(0,-1).join("/")+"/";t.configureFlowplayer=function(j,n,u){return u};t.createFallback=function(j,n){var u=y(n,"controls"),x=n.getAttribute("poster")||"",G=n.getAttribute("src")||"",I;if(G)I=B(j,G);else v(n.getElementsByTagName("source"),function(s){var D=s.getAttribute("src");D&&!G&&v(h,function(H){I=B(j,D,s.getAttribute("type"));if(E(I)==E(H))G=D})});var g=o.createElement("span");g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=A(n,"width","300px");g.style.height=A(n,"height","24px");n.parentNode.replaceChild(g,n);var q=(n.getAttribute("preload")||"").toLowerCase(),i=[];x&&i.push({url:C(x)});if(G)i.push({url:C(G),autoPlay:y(n,"autoplay"),autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(q==""||q=="auto"),onBeforeFinish:function(){return!y(n,"loop")}});x={controls:u&&{url:C(t.flowplayerControlsSwf),fullscreen:false,autoHide:j==p&&"always"||"never"}||null};if(E(I)==E(f)){x.audio={url:C(t.flowplayerAudioSwf)};u||(x.controls={url:C(t.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}u={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:x};t.configureFlowplayer(j,n,u);flowplayer(g,{src:C(t.flowplayerSwf),wmode:"opaque"},u)};if(z.jQuery)jQuery(t);else z.DomReady&&DomReady.ready(t);z.html5media=t})(this,document); |
" g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=D(n,"width","300px");g.style.height=D(n,"height","24px");n.parentNode.replaceChild(g,n);var p=(n.getAttribute("preload")||"").toLowerCase(),i=[];w&&i.push({url:B(w)});if(G)i.push({url:B(G),autoPlay:y(n,"autoplay"),autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(p==""||p=="auto"),onBeforeFinish:function(){return!y(n,"loop")}});w={controls:t&&{url:B(s.flowplayerControlsSwf),fullscreen:false,autoHide:j==x&&"always"|| "never"}||null};if(E(I)==E(d)){w.audio={url:B(s.flowplayerAudioSwf)};t||(w.controls={url:B(s.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}t={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:w};s.configureFlowplayer(j,n,t);flowplayer(g,{src:B(s.flowplayerSwf),wmode:"opaque"},t)};if(A.jQuery)jQuery(s);else A.DomReady&&DomReady.ready(s);A.html5media=s})(this,document); | "3gpp":b,"3g2":b,mpg:b,mpeg:b},audio:{ogg:c,oga:c,aac:m,m4a:m,mp3:d,wav:l}},q=A.location.protocol+" z&&!G&&v(h,function(H){I=F(j,z,r.getAttribute("type"));if(E(I)==E(H))G=z})});var g=o.createElement("span");g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=D(n,"width","300px");g.style.height=D(n,"height","24px");n.parentNode.replaceChild(g,n);var p=(n.getAttribute("preload")||"").toLowerCase(),i=[];w&&i.push({url:B(w)});if(G)i.push({url:B(G),autoPlay:y(n,"autoplay"),autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(p==""||p=="auto"),onBeforeFinish:function(){return!y(n, "loop")}});w={controls:t&&{url:B(s.flowplayerControlsSwf),fullscreen:false,autoHide:j==x&&"always"||"never"}||null};if(E(I)==E(d)){w.audio={url:B(s.flowplayerAudioSwf)};t||(w.controls={url:B(s.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}t={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:w};s.configureFlowplayer(j,n,t);flowplayer(g,{src:B(s.flowplayerSwf),wmode:"opaque"},t)};if(A.jQuery)jQuery(s);else A.DomReady&&DomReady.ready(s);A.html5media= | "//"+A.location.host,u=String(A.location);v(o.getElementsByTagName("base"),function(j){if(j.href)u=j.href});u=u.split("/").slice(0,-1).join("/")+"/";s.configureFlowplayer=function(j,n,t){return t};s.createFallback=function(j,n){var t=y(n,"controls"),w=n.getAttribute("poster")||"",G=n.getAttribute("src")||"",I;if(G)I=F(j,G);else v(n.getElementsByTagName("source"),function(r){var z=r.getAttribute("src");z&&!G&&v(h,function(H){I=F(j,z,r.getAttribute("type"));if(E(I)==E(H))G=z})});var g=o.createElement("span");g.id=n.id;g.className=n.className;g.title=n.title;g.style.display="block";g.style.width=D(n,"width","300px");g.style.height=D(n,"height","24px");n.parentNode.replaceChild(g,n);var p=(n.getAttribute("preload")||"").toLowerCase(),i=[];w&&i.push({url:B(w)});if(G)i.push({url:B(G),autoPlay:y(n,"autoplay"),autoBuffering:y(n,"autobuffer")||y(n,"preload")&&(p==""||p=="auto"),onBeforeFinish:function(){return!y(n,"loop")}});w={controls:t&&{url:B(s.flowplayerControlsSwf),fullscreen:false,autoHide:j==x&&"always"||"never"}||null};if(E(I)==E(d)){w.audio={url:B(s.flowplayerAudioSwf)};t||(w.controls={url:B(s.flowplayerControlsSwf),display:"none"});i.slice(-1)[0].autoBuffering=false}t={play:null,playlist:i,clip:{scaling:"fit",fadeInSpeed:0,fadeOutSpeed:0},plugins:w};s.configureFlowplayer(j,n,t);flowplayer(g,{src:B(s.flowplayerSwf),wmode:"opaque"},t)};if(A.jQuery)jQuery(s);else A.DomReady&&DomReady.ready(s);A.html5media=s})(this,document); |
},getParent:function(){var h=this.$.parentNode;return h&&h.nodeType==1?new d.node(h):null;},getParents:function(h){var i=this,j=[];do j[h?'push':'unshift'](i);while(i=i.getParent())return j;},getCommonAncestor:function(h){var j=this;if(h.equals(j))return j;if(h.contains&&h.contains(j))return h;var i=j.contains?j:j.getParent();do{if(i.contains(h))return i;}while(i=i.getParent())return null;},getPosition:function(h){var i=this.$,j=h.$;if(i.compareDocumentPosition)return i.compareDocumentPosition(j);if(i==j)return 0;if(this.type==1&&h.type==1){if(i.contains){if(i.contains(j))return 16+4;if(j.contains(i))return 8+2;}if('sourceIndex' in i)return i.sourceIndex<0||j.sourceIndex<0?1:i.sourceIndex<j.sourceIndex?4:2;}var k=this.getAddress(),l=h.getAddress(),m=Math.min(k.length,l.length);for(var n=0;n<=m-1;n++){if(k[n]!=l[n]){if(n<m)return k[n]<l[n]?4:2;break;}}return k.length<l.length?16+4:8+2;},getAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return new d.node(j);j=j.parentNode;}return null;},hasAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return true;j=j.parentNode;}return false;},move:function(h,i){h.append(this.remove(),i);},remove:function(h){var i=this.$,j=i.parentNode;if(j){if(h)for(var k;k=i.firstChild;)j.insertBefore(i.removeChild(k),i);j.removeChild(i);}return this;},replace:function(h){this.insertBefore(h);h.remove();},trim:function(){this.ltrim();this.rtrim();},ltrim:function(){var k=this;var h;while(k.getFirst&&(h=k.getFirst())){if(h.type==3){var i=e.ltrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(j-i.length);k.$.removeChild(k.$.firstChild);}}break;}},rtrim:function(){var k=this;var h;while(k.getLast&&(h=k.getLast())){if(h.type==3){var i=e.rtrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(i.length);k.$.lastChild.parentNode.removeChild(k.$.lastChild);}}break;}if(!c&&!b.opera){h=k.$.lastChild;if(h&&h.type==1&&h.nodeName.toLowerCase()=='br')h.parentNode.removeChild(h);}}});d.nodeList=function(h){this.$=h;};d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j); k.setHtml(i);return k.getFirst().remove();};h.setMarker=function(i,j,k,l){var m=j.getCustomData('list_marker_id')||j.setCustomData('list_marker_id',e.getNextNumber()).getCustomData('list_marker_id'),n=j.getCustomData('list_marker_names')||j.setCustomData('list_marker_names',{}).getCustomData('list_marker_names');i[m]=j;n[k]=1;return j.setCustomData(k,l);};h.clearAllMarkers=function(i){for(var j in i)h.clearMarkers(i,i[j],true);};h.clearMarkers=function(i,j,k){var l=j.getCustomData('list_marker_names'),m=j.getCustomData('list_marker_id');for(var n in l)j.removeCustomData(n);j.removeCustomData('list_marker_names');if(k){j.removeCustomData('list_marker_id');delete i[m];}};e.extend(h.prototype,{type:1,addClass:function(i){var j=this.$.className;if(j){var k=new RegExp('(?:^|\\s)'+i+'(?:\\s|$)','');if(!k.test(j))j+=' '+i;}this.$.className=j||i;},removeClass:function(i){var j=this.getAttribute('class');if(j){var k=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','i');if(k.test(j)){j=j.replace(k,'').replace(/^\s+/,'');if(j)this.setAttribute('class',j);else this.removeAttribute('class');}}},hasClass:function(i){var j=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','');return j.test(this.getAttribute('class'));},append:function(i,j){var k=this;if(typeof i=='string')i=k.getDocument().createElement(i);if(j)k.$.insertBefore(i.$,k.$.firstChild);else k.$.appendChild(i.$);return i;},appendHtml:function(i){var k=this;if(!k.$.childNodes.length)k.setHtml(i);else{var j=new h('div',k.getDocument());j.setHtml(i);j.moveChildren(k);}},appendText:function(i){if(this.$.text!=undefined)this.$.text+=i;else this.append(new d.text(i));},appendBogus:function(){var k=this;var i=k.getLast();while(i&&i.type==3&&!e.rtrim(i.getText()))i=i.getPrevious();if(!i||!i.is||!i.is('br')){var j=b.opera?k.getDocument().createText(''):k.getDocument().createElement('br');b.gecko&&j.setAttribute('type','_moz');k.append(j);}},breakParent:function(i){var l=this;var j=new d.range(l.getDocument());j.setStartAfter(l);j.setEndAfter(i);var k=j.extractContents();j.insertNode(l.remove());k.insertAfterNode(l);},contains:c||b.webkit?function(i){var j=this.$;return i.type!=1?j.contains(i.getParent().$):j!=i.$&&j.contains(i.$);}:function(i){return!!(this.$.compareDocumentPosition(i.$)&16);},focus:function(){try{this.$.focus();}catch(i){}},getHtml:function(){var i=this.$.innerHTML;return c?i.replace(/<\?[^>]*>/g,''):i;},getOuterHtml:function(){var j=this;if(j.$.outerHTML)return j.$.outerHTML.replace(/<\?[^>]*>/,'');var i=j.$.ownerDocument.createElement('div'); | };d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j);k.setHtml(i);return k.getFirst().remove();};h.setMarker=function(i,j,k,l){var m=j.getCustomData('list_marker_id')||j.setCustomData('list_marker_id',e.getNextNumber()).getCustomData('list_marker_id'),n=j.getCustomData('list_marker_names')||j.setCustomData('list_marker_names',{}).getCustomData('list_marker_names');i[m]=j;n[k]=1;return j.setCustomData(k,l);};h.clearAllMarkers=function(i){for(var j in i)h.clearMarkers(i,i[j],true);};h.clearMarkers=function(i,j,k){var l=j.getCustomData('list_marker_names'),m=j.getCustomData('list_marker_id');for(var n in l)j.removeCustomData(n);j.removeCustomData('list_marker_names');if(k){j.removeCustomData('list_marker_id');delete i[m];}};e.extend(h.prototype,{type:1,addClass:function(i){var j=this.$.className;if(j){var k=new RegExp('(?:^|\\s)'+i+'(?:\\s|$)','');if(!k.test(j))j+=' '+i;}this.$.className=j||i;},removeClass:function(i){var j=this.getAttribute('class');if(j){var k=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','i');if(k.test(j)){j=j.replace(k,'').replace(/^\s+/,'');if(j)this.setAttribute('class',j);else this.removeAttribute('class');}}},hasClass:function(i){var j=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','');return j.test(this.getAttribute('class'));},append:function(i,j){var k=this;if(typeof i=='string')i=k.getDocument().createElement(i);if(j)k.$.insertBefore(i.$,k.$.firstChild);else k.$.appendChild(i.$);return i;},appendHtml:function(i){var k=this;if(!k.$.childNodes.length)k.setHtml(i);else{var j=new h('div',k.getDocument());j.setHtml(i);j.moveChildren(k);}},appendText:function(i){if(this.$.text!=undefined)this.$.text+=i;else this.append(new d.text(i));},appendBogus:function(){var k=this;var i=k.getLast();while(i&&i.type==3&&!e.rtrim(i.getText()))i=i.getPrevious();if(!i||!i.is||!i.is('br')){var j=b.opera?k.getDocument().createText(''):k.getDocument().createElement('br');b.gecko&&j.setAttribute('type','_moz');k.append(j);}},breakParent:function(i){var l=this;var j=new d.range(l.getDocument());j.setStartAfter(l);j.setEndAfter(i);var k=j.extractContents();j.insertNode(l.remove());k.insertAfterNode(l);},contains:c||b.webkit?function(i){var j=this.$;return i.type!=1?j.contains(i.getParent().$):j!=i.$&&j.contains(i.$); | },getParent:function(){var h=this.$.parentNode;return h&&h.nodeType==1?new d.node(h):null;},getParents:function(h){var i=this,j=[];do j[h?'push':'unshift'](i);while(i=i.getParent())return j;},getCommonAncestor:function(h){var j=this;if(h.equals(j))return j;if(h.contains&&h.contains(j))return h;var i=j.contains?j:j.getParent();do{if(i.contains(h))return i;}while(i=i.getParent())return null;},getPosition:function(h){var i=this.$,j=h.$;if(i.compareDocumentPosition)return i.compareDocumentPosition(j);if(i==j)return 0;if(this.type==1&&h.type==1){if(i.contains){if(i.contains(j))return 16+4;if(j.contains(i))return 8+2;}if('sourceIndex' in i)return i.sourceIndex<0||j.sourceIndex<0?1:i.sourceIndex<j.sourceIndex?4:2;}var k=this.getAddress(),l=h.getAddress(),m=Math.min(k.length,l.length);for(var n=0;n<=m-1;n++){if(k[n]!=l[n]){if(n<m)return k[n]<l[n]?4:2;break;}}return k.length<l.length?16+4:8+2;},getAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return new d.node(j);j=j.parentNode;}return null;},hasAscendant:function(h,i){var j=this.$;if(!i)j=j.parentNode;while(j){if(j.nodeName&&j.nodeName.toLowerCase()==h)return true;j=j.parentNode;}return false;},move:function(h,i){h.append(this.remove(),i);},remove:function(h){var i=this.$,j=i.parentNode;if(j){if(h)for(var k;k=i.firstChild;)j.insertBefore(i.removeChild(k),i);j.removeChild(i);}return this;},replace:function(h){this.insertBefore(h);h.remove();},trim:function(){this.ltrim();this.rtrim();},ltrim:function(){var k=this;var h;while(k.getFirst&&(h=k.getFirst())){if(h.type==3){var i=e.ltrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(j-i.length);k.$.removeChild(k.$.firstChild);}}break;}},rtrim:function(){var k=this;var h;while(k.getLast&&(h=k.getLast())){if(h.type==3){var i=e.rtrim(h.getText()),j=h.getLength();if(!i){h.remove();continue;}else if(i.length<j){h.split(i.length);k.$.lastChild.parentNode.removeChild(k.$.lastChild);}}break;}if(!c&&!b.opera){h=k.$.lastChild;if(h&&h.type==1&&h.nodeName.toLowerCase()=='br')h.parentNode.removeChild(h);}}});d.nodeList=function(h){this.$=h;};d.nodeList.prototype={count:function(){return this.$.length;},getItem:function(h){var i=this.$[h];return i?new d.node(i):null;}};d.element=function(h,i){if(typeof h=='string')h=(i?i.$:document).createElement(h);d.domObject.call(this,h);};var h=d.element;h.get=function(i){return i&&(i.$?i:new h(i));};h.prototype=new d.node();h.createFromHtml=function(i,j){var k=new h('div',j);k.setHtml(i);return k.getFirst().remove();};h.setMarker=function(i,j,k,l){var m=j.getCustomData('list_marker_id')||j.setCustomData('list_marker_id',e.getNextNumber()).getCustomData('list_marker_id'),n=j.getCustomData('list_marker_names')||j.setCustomData('list_marker_names',{}).getCustomData('list_marker_names');i[m]=j;n[k]=1;return j.setCustomData(k,l);};h.clearAllMarkers=function(i){for(var j in i)h.clearMarkers(i,i[j],true);};h.clearMarkers=function(i,j,k){var l=j.getCustomData('list_marker_names'),m=j.getCustomData('list_marker_id');for(var n in l)j.removeCustomData(n);j.removeCustomData('list_marker_names');if(k){j.removeCustomData('list_marker_id');delete i[m];}};e.extend(h.prototype,{type:1,addClass:function(i){var j=this.$.className;if(j){var k=new RegExp('(?:^|\\s)'+i+'(?:\\s|$)','');if(!k.test(j))j+=' '+i;}this.$.className=j||i;},removeClass:function(i){var j=this.getAttribute('class');if(j){var k=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','i');if(k.test(j)){j=j.replace(k,'').replace(/^\s+/,'');if(j)this.setAttribute('class',j);else this.removeAttribute('class');}}},hasClass:function(i){var j=new RegExp('(?:^|\\s+)'+i+'(?=\\s|$)','');return j.test(this.getAttribute('class'));},append:function(i,j){var k=this;if(typeof i=='string')i=k.getDocument().createElement(i);if(j)k.$.insertBefore(i.$,k.$.firstChild);else k.$.appendChild(i.$);return i;},appendHtml:function(i){var k=this;if(!k.$.childNodes.length)k.setHtml(i);else{var j=new h('div',k.getDocument());j.setHtml(i);j.moveChildren(k);}},appendText:function(i){if(this.$.text!=undefined)this.$.text+=i;else this.append(new d.text(i));},appendBogus:function(){var k=this;var i=k.getLast();while(i&&i.type==3&&!e.rtrim(i.getText()))i=i.getPrevious();if(!i||!i.is||!i.is('br')){var j=b.opera?k.getDocument().createText(''):k.getDocument().createElement('br');b.gecko&&j.setAttribute('type','_moz');k.append(j);}},breakParent:function(i){var l=this;var j=new d.range(l.getDocument());j.setStartAfter(l);j.setEndAfter(i);var k=j.extractContents();j.insertNode(l.remove());k.insertAfterNode(l);},contains:c||b.webkit?function(i){var j=this.$;return i.type!=1?j.contains(i.getParent().$):j!=i.$&&j.contains(i.$);}:function(i){return!!(this.$.compareDocumentPosition(i.$)&16);},focus:function(){try{this.$.focus();}catch(i){}},getHtml:function(){var i=this.$.innerHTML;return c?i.replace(/<\?[^>]*>/g,''):i;},getOuterHtml:function(){var j=this;if(j.$.outerHTML)return j.$.outerHTML.replace(/<\?[^>]*>/,'');var i=j.$.ownerDocument.createElement('div'); |
this.hostPanel.cardPanel.getLayout().activeItem.getComponent(0).presetData = defaultData; | this.hostPanel.cardPanel.getLayout().activeItem.items.get(0).presetData = defaultData; this.hostPanel.cardPanel.getLayout().activeItem.items.get(0).resetHandler(); | createRoleMapping : function(button, e) { if (this.hostPanel) { var roleId = this.find('name', 'roleId')[0].getValue(); var roleRec = this.roleStore.getById(roleId); var sourceId = this.find('name', 'source')[0].getValue(); var handler = this.hostPanel.addActionHandler.createDelegate(this.hostPanel, [function(rec, item, e) { rec.beginEdit(); rec.set('source', sourceId); rec.set('mapping', sourceId); rec.commit(); rec.endEdit(); }, { autoCreateNewRecord : true, text : "Role Mapping" }], 0); handler(); var defaultData = { id : roleId, name : roleRec.data.name, description : 'External mapping for ' + roleRec.data.name + ' (' + sourceId + ')' }; this.hostPanel.cardPanel.getLayout().activeItem.find('name', 'id')[0].disable(); this.hostPanel.cardPanel.getLayout().activeItem.getComponent(0).presetData = defaultData; this.close(); } } |
if (params.name) this.lines[This.lineNum].staff[This.staffNum].title = params.name; | if (params.name) This.lines[This.lineNum].staff[This.staffNum].title = params.name; if (params.fontVocal) This.lines[This.lineNum].staff[This.staffNum].fontVocal = params.fontVocal; | var createStaff = function(params) { This.lines[This.lineNum].staff[This.staffNum] = { voices: [ ]}; if (params.name) this.lines[This.lineNum].staff[This.staffNum].title = params.name; createVoice(params); }; |
if (params.name) This.lines[This.lineNum].staff[This.staffNum].title = params.name; | var createStaff = function(params) { This.lines[This.lineNum].staff[This.staffNum] = { voices: [ ]}; if (params.name) This.lines[This.lineNum].staff[This.staffNum].title = params.name; if (params.fontVocal) This.lines[This.lineNum].staff[This.staffNum].fontVocal = params.fontVocal; createVoice(params); }; |
|
if (params.part) This.appendElement('part', params.startChar, params.endChar, {title: params.part}); This.appendStartingElement('clef', params.startChar, params.endChar, params.clef ); This.appendStartingElement('key', params.startChar, params.endChar, params.key); if (params.meter !== undefined) This.appendStartingElement('meter', params.startChar, params.endChar, params.meter); | var createStaff = function(params) { This.lines[This.lineNum].staff[This.staffNum] = { voices: [ ]}; if (params.name) This.lines[This.lineNum].staff[This.staffNum].title = params.name; if (params.fontVocal) This.lines[This.lineNum].staff[This.staffNum].fontVocal = params.fontVocal; createVoice(params); }; |
|
strokeOpacity: strokeOpacity, | strokeOpacity: strokeOpacity | OLStyleFactory.createStyleMap_Line = function(strokeColor,strokeWidth,strokeOpacity) { var default_style = new OpenLayers.Style({ strokeColor: strokeColor, strokeWidth: strokeWidth, strokeOpacity: strokeOpacity, }); // create style map class var styleMap = new OpenLayers.StyleMap({ "default": default_style, "select": { fillColor: "#8aeeef", strokeColor: "#32a8a9" }, "temporary" : { fontColor: "#000000", fillColor: "#ff6666", strokeColor: "#f00000" } }); return styleMap;} |
+ documentNode.textContent | + textContent | var createTreeNode = function(documentNode) { var treeNode = null; // We have a leaf if (isLeafNode(documentNode)) { treeNode = new Ext.tree.TreeNode( { text : documentNode.tagName + " = " + documentNode.textContent }); } else { // we have a parent node var parentName = documentNode.tagName; if (documentNode.attributes.length > 0) { parentName += '('; for ( var i = 0; i < documentNode.attributes.length; i++) { parentName += ' ' + documentNode.attributes[i].nodeName + '=' + documentNode.attributes[i].value; } parentName += ')'; } treeNode = new Ext.tree.TreeNode( { text : parentName }); } return treeNode; }; |
This.appendStartingElement('clef', params.startChar, params.endChar, {type: params.clef }); | This.appendStartingElement('clef', params.startChar, params.endChar, params.clef ); | var createVoice = function(params) { This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = []; if (params.part) This.appendElement('part', params.startChar, params.endChar, {title: params.part}); This.appendStartingElement('clef', params.startChar, params.endChar, {type: params.clef }); This.appendStartingElement('key', params.startChar, params.endChar, params.key); if (params.meter !== undefined) This.appendStartingElement('meter', params.startChar, params.endChar, params.meter); }; |
if (params.part) This.appendElement('part', params.startChar, params.endChar, {title: params.part}); This.appendStartingElement('clef', params.startChar, params.endChar, params.clef ); This.appendStartingElement('key', params.startChar, params.endChar, params.key); if (params.meter !== undefined) This.appendStartingElement('meter', params.startChar, params.endChar, params.meter); | if (This.isFirstLine(This.lineNum)) { if (params.name) { if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = []; This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.name; } } else { if (params.subname) { if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = []; This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.subname; } } | var createVoice = function(params) { This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = []; if (params.part) This.appendElement('part', params.startChar, params.endChar, {title: params.part}); This.appendStartingElement('clef', params.startChar, params.endChar, params.clef ); This.appendStartingElement('key', params.startChar, params.endChar, params.key); if (params.meter !== undefined) This.appendStartingElement('meter', params.startChar, params.endChar, params.meter); }; |
var title = layerDef.Title; var options = layerDef.Options; | var delimiter = '?'; if (options['map'] != null) { wfs_url = layerDef.Url+delimiter+"map="+options['map']; delimiter = '&'; } | function createWFSLayer(layerDef) { var wfs_url = layerDef.Url; var title = layerDef.Title; var options = layerDef.Options; var featureType = layerDef.ogc_name; var layer = new OpenLayers.Layer.WFS(title, wfs_url, options); return layer;} |
var layer = new OpenLayers.Layer.WFS(title, wfs_url, options); | var p = new OpenLayers.Protocol.WFS({ url: wfs_url, featureType: featureType, featurePrefix: null }); p.wfs_url = wfs_url + delimiter; p.format.setNamespace("feature", "http: strategies = [ new OpenLayers.Strategy.Fixed() ]; layer = new OpenLayers.Layer.Vector(title, { strategies: strategies, protocol: p }); | function createWFSLayer(layerDef) { var wfs_url = layerDef.Url; var title = layerDef.Title; var options = layerDef.Options; var featureType = layerDef.ogc_name; var layer = new OpenLayers.Layer.WFS(title, wfs_url, options); return layer;} |
d.fn.css=function(a,b){return S(this,a,b,true,function(e,g,h){if(h===v)return d.curCSS(e,g);if(typeof h==="number"&&!Oa.test(g))h+="px";d.style(e,g,h)})};d.extend({style:function(a,b,e){if(!a||a.nodeType===3||a.nodeType===8)return v;if((b==="width"||b==="height")&&parseFloat(e)<0)e=v;var g=a.style||a,h=e!==v;if(!d.support.opacity&&b==="opacity"){if(h){g.zoom=1;b=parseInt(e,10)+""==="NaN"?"":"alpha(opacity="+e*100+")";a=g.filter||d.curCSS(a,"filter")||"";g.filter=ma.test(a)?a.replace(ma,b):b}return g.filter&& | "Bottom"],Va=r.defaultView&&r.defaultView.getComputedStyle,pa=c.support.cssFloat?"cssFloat":"styleFloat",qa=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return S(this,a,b,true,function(e,f,h){if(h===v)return c.curCSS(e,f);if(typeof h==="number"&&!Oa.test(f))h+="px";c.style(e,f,h)})};c.extend({style:function(a,b,e){if(!a||a.nodeType===3||a.nodeType===8)return v;if((b==="width"||b==="height")&&parseFloat(e)<0)e=v;var f=a.style||a,h=e!==v;if(!c.support.opacity&&b==="opacity"){if(h){f.zoom= | d.fn.css=function(a,b){return S(this,a,b,true,function(e,g,h){if(h===v)return d.curCSS(e,g);if(typeof h==="number"&&!Oa.test(g))h+="px";d.style(e,g,h)})};d.extend({style:function(a,b,e){if(!a||a.nodeType===3||a.nodeType===8)return v;if((b==="width"||b==="height")&&parseFloat(e)<0)e=v;var g=a.style||a,h=e!==v;if(!d.support.opacity&&b==="opacity"){if(h){g.zoom=1;b=parseInt(e,10)+""==="NaN"?"":"alpha(opacity="+e*100+")";a=g.filter||d.curCSS(a,"filter")||"";g.filter=ma.test(a)?a.replace(ma,b):b}return g.filter&& |
0?l():d.swap(a,Sa,l);return Math.max(0,Math.round(h))}return d.curCSS(a,b,e)},curCSS:function(a,b,e){var g,h=a.style;if(!d.support.opacity&&b==="opacity"&&a.currentStyle){g=na.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return g===""?"1":g}if(X.test(b))b=pa;if(!e&&h&&h[b])g=h[b];else if(Va){if(X.test(b))b="float";b=b.replace(Pa,"-$1").toLowerCase();h=a.ownerDocument.defaultView;if(!h)return null;if(a=h.getComputedStyle(a,null))g=a.getPropertyValue(b);if(b==="opacity"&&g==="")g= "1"}else if(a.currentStyle){e=b.replace(oa,qa);g=a.currentStyle[b]||a.currentStyle[e];if(!Qa.test(g)&&Ra.test(g)){b=h.left;var k=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=e==="fontSize"?"1em":g||0;g=h.pixelLeft+"px";h.left=b;a.runtimeStyle.left=k}}return g},swap:function(a,b,e){var g={};for(var h in b){g[h]=a.style[h];a.style[h]=b[h]}e.call(a);for(h in b)a.style[h]=g[h]}});if(d.expr&&d.expr.filters){d.expr.filters.hidden=function(a){var b=a.offsetWidth,e=a.offsetHeight,g= | true))||0);if(f==="margin")h+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else h-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?l():c.swap(a,Sa,l);return Math.max(0,Math.round(h))}return c.curCSS(a,b,e)},curCSS:function(a,b,e){var f,h=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=na.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(X.test(b))b=pa;if(!e&&h&&h[b])f=h[b];else if(Va){if(X.test(b))b="float";b=b.replace(Pa, "-$1").toLowerCase();h=a.ownerDocument.defaultView;if(!h)return null;if(a=h.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){e=b.replace(oa,qa);f=a.currentStyle[b]||a.currentStyle[e];if(!Qa.test(f)&&Ra.test(f)){b=h.left;var k=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=e==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=b;a.runtimeStyle.left=k}}return f},swap:function(a,b,e){var f={};for(var h in b){f[h]=a.style[h];a.style[h]= | 0?l():d.swap(a,Sa,l);return Math.max(0,Math.round(h))}return d.curCSS(a,b,e)},curCSS:function(a,b,e){var g,h=a.style;if(!d.support.opacity&&b==="opacity"&&a.currentStyle){g=na.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return g===""?"1":g}if(X.test(b))b=pa;if(!e&&h&&h[b])g=h[b];else if(Va){if(X.test(b))b="float";b=b.replace(Pa,"-$1").toLowerCase();h=a.ownerDocument.defaultView;if(!h)return null;if(a=h.getComputedStyle(a,null))g=a.getPropertyValue(b);if(b==="opacity"&&g==="")g="1"}else if(a.currentStyle){e=b.replace(oa,qa);g=a.currentStyle[b]||a.currentStyle[e];if(!Qa.test(g)&&Ra.test(g)){b=h.left;var k=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=e==="fontSize"?"1em":g||0;g=h.pixelLeft+"px";h.left=b;a.runtimeStyle.left=k}}return g},swap:function(a,b,e){var g={};for(var h in b){g[h]=a.style[h];a.style[h]=b[h]}e.call(a);for(h in b)a.style[h]=g[h]}});if(d.expr&&d.expr.filters){d.expr.filters.hidden=function(a){var b=a.offsetWidth,e=a.offsetHeight,g= |
hasMoreRows:function(){return this.numRows>this.rowIndex},next:function(){this.row=this.rows.item(++this.rowIndex)},curr:function(){return this.rowIndex},rowCount:function(){return this.numRows},reset:function(){this.rowIndex=0;this.row=this.hasMoreRows()?this.rows.item(this.rowIndex):null},fieldDef:function(a){var b=this.fields[a];j(b)&&Xmla.Exception._newError("INVALID_FIELD","Xmla.Rowset.fieldDef",a)._throw();return b},fieldIndex:function(a){a=this.fieldDef(a);return a.index},fieldName:function(a){var b= | return a},hasMoreRows:function(){return this.numRows>this.rowIndex},next:function(){this.rowIndex+=1;this.row=this.rows.item(this.rowIndex)},curr:function(){return this.rowIndex},rowCount:function(){return this.numRows},reset:function(){this.rowIndex=0;this.row=this.hasMoreRows()?this.rows.item(this.rowIndex):null},fieldDef:function(a){var b=this.fields[a];j(b)&&Xmla.Exception._newError("INVALID_FIELD","Xmla.Rowset.fieldDef",a)._throw();return b},fieldIndex:function(a){a=this.fieldDef(a);return a.index}, | hasMoreRows:function(){return this.numRows>this.rowIndex},next:function(){this.row=this.rows.item(++this.rowIndex)},curr:function(){return this.rowIndex},rowCount:function(){return this.numRows},reset:function(){this.rowIndex=0;this.row=this.hasMoreRows()?this.rows.item(this.rowIndex):null},fieldDef:function(a){var b=this.fields[a];j(b)&&Xmla.Exception._newError("INVALID_FIELD","Xmla.Rowset.fieldDef",a)._throw();return b},fieldIndex:function(a){a=this.fieldDef(a);return a.index},fieldName:function(a){var b= |
WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,t,g){function n(c){var e,h,i,q=a.getElement(t).firstChild.childNodes;h=e=0;for(i=q.length;h<i;h++){var s=q[h];if(a.hasTag(s,"COLGROUP")){h=-1;q=s.childNodes;i=q.length}if(a.hasTag(s,"COL"))if(s.className!="Wt-vrh")if(e==c)return s;else++e}return null}function d(c,e){if(c.offsetWidth>0)return c.offsetWidth;else{c=m.firstChild.rows[0];var h,i,q,s;q=i=0;for(s=c.childNodes.length;i<s;++i){h=c.childNodes[i];if(h.className!="Wt-vrh"){if(q== e)return h.offsetWidth;q+=h.colSpan}}return 0}}function k(c,e){var h=a.getElement(t).firstChild;n(c).style.width=e+"px";var i,q,s,v;q=i=0;for(s=h.rows.length;i<s;i++){v=h.rows[i];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<F;++B){w=v.childNodes[B];if(w.className!="Wt-vrh"){if(w.colSpan==1&&D==c&&w.childNodes.length==1){v=w.firstChild;w=e-r.marginH(v);v.style.width=w+"px";break}D+=w.colSpan}}++q}}}function l(c,e,h){var i=c.firstChild;new a.SizeHandle(a,"v",i.offsetHeight, | WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,t,i){function o(c){var f,j,l,q=a.getElement(t).firstChild.childNodes;j=f=0;for(l=q.length;j<l;j++){var s=q[j];if(a.hasTag(s,"COLGROUP")){j=-1;q=s.childNodes;l=q.length}if(a.hasTag(s,"COL"))if(s.className!="Wt-vrh")if(f==c)return s;else++f}return null}function d(c,f){if(c.offsetWidth>0)return c.offsetWidth;else{c=n.firstChild.rows[0];var j,l,q,s;q=l=0;for(s=c.childNodes.length;l<s;++l){j=c.childNodes[l];if(j.className!="Wt-vrh"){if(q== f)return j.offsetWidth;q+=j.colSpan}}return 0}}function e(c,f){var j=a.getElement(t).firstChild;o(c).style.width=f+"px";var l,q,s,v;q=l=0;for(s=j.rows.length;l<s;l++){v=j.rows[l];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<F;++B){w=v.childNodes[B];if(w.className!="Wt-vrh"){if(w.colSpan==1&&D==c&&w.childNodes.length==1){v=w.firstChild;w=f-r.marginH(v);v.style.width=w+"px";break}D+=w.colSpan}}++q}}}function g(c,f,j){var l=c.firstChild;new a.SizeHandle(a,"v",l.offsetHeight, | WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,t,g){function n(c){var e,h,i,q=a.getElement(t).firstChild.childNodes;h=e=0;for(i=q.length;h<i;h++){var s=q[h];if(a.hasTag(s,"COLGROUP")){h=-1;q=s.childNodes;i=q.length}if(a.hasTag(s,"COL"))if(s.className!="Wt-vrh")if(e==c)return s;else++e}return null}function d(c,e){if(c.offsetWidth>0)return c.offsetWidth;else{c=m.firstChild.rows[0];var h,i,q,s;q=i=0;for(s=c.childNodes.length;i<s;++i){h=c.childNodes[i];if(h.className!="Wt-vrh"){if(q==e)return h.offsetWidth;q+=h.colSpan}}return 0}}function k(c,e){var h=a.getElement(t).firstChild;n(c).style.width=e+"px";var i,q,s,v;q=i=0;for(s=h.rows.length;i<s;i++){v=h.rows[i];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<F;++B){w=v.childNodes[B];if(w.className!="Wt-vrh"){if(w.colSpan==1&&D==c&&w.childNodes.length==1){v=w.firstChild;w=e-r.marginH(v);v.style.width=w+"px";break}D+=w.colSpan}}++q}}}function l(c,e,h){var i=c.firstChild;new a.SizeHandle(a,"v",i.offsetHeight, |
var _$_WT_CLASS_$_=new (function(){function w(a,b){return a.style[b]?a.style[b]:document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(a,null)[b]:a.currentStyle?a.currentStyle[b]:null}function t(a){if(B==null)return null;if(!a)a=window.event;if(a){for(var b=a=g.target(a);b&&b!=B;)b=b.parentNode;return b==B?g.isIE?a:null:B}else return B}function D(a){var b=t(a);if(b&&!S){if(!a)a=window.event;S=true;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmousemove", a);g.firedTarget=null}else g.condCall(b,"onmousemove",a);return S=false}else return true}function T(a){var b=t(a);g.capture(null);if(b){if(!a)a=window.event;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmouseup",a);g.firedTarget=null}else g.condCall(b,"onmouseup",a);g.cancelEvent(a,g.CancelPropagate);return false}else return true}function ca(){if(!Y){Y=true;if(document.body.addEventListener){var a=document.body;a.addEventListener("mousemove",D,true);a.addEventListener("mouseup",T,true); | var _$_WT_CLASS_$_=new (function(){function x(a,b){return a.style[b]?a.style[b]:document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(a,null)[b]:a.currentStyle?a.currentStyle[b]:null}function u(a){if(B==null)return null;if(!a)a=window.event;if(a){for(var b=a=g.target(a);b&&b!=B;)b=b.parentNode;return b==B?g.isIE?a:null:B}else return B}function D(a){var b=u(a);if(b&&!S){if(!a)a=window.event;S=true;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmousemove", a);g.firedTarget=null}else g.condCall(b,"onmousemove",a);return S=false}else return true}function T(a){var b=u(a);g.capture(null);if(b){if(!a)a=window.event;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmouseup",a);g.firedTarget=null}else g.condCall(b,"onmouseup",a);g.cancelEvent(a,g.CancelPropagate);return false}else return true}function ca(){if(!U){U=true;if(document.body.addEventListener){var a=document.body;a.addEventListener("mousemove",D,true);a.addEventListener("mouseup",T,true); | var _$_WT_CLASS_$_=new (function(){function w(a,b){return a.style[b]?a.style[b]:document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(a,null)[b]:a.currentStyle?a.currentStyle[b]:null}function t(a){if(B==null)return null;if(!a)a=window.event;if(a){for(var b=a=g.target(a);b&&b!=B;)b=b.parentNode;return b==B?g.isIE?a:null:B}else return B}function D(a){var b=t(a);if(b&&!S){if(!a)a=window.event;S=true;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmousemove",a);g.firedTarget=null}else g.condCall(b,"onmousemove",a);return S=false}else return true}function T(a){var b=t(a);g.capture(null);if(b){if(!a)a=window.event;if(g.isIE){g.firedTarget=a.srcElement||b;b.fireEvent("onmouseup",a);g.firedTarget=null}else g.condCall(b,"onmouseup",a);g.cancelEvent(a,g.CancelPropagate);return false}else return true}function ca(){if(!Y){Y=true;if(document.body.addEventListener){var a=document.body;a.addEventListener("mousemove",D,true);a.addEventListener("mouseup",T,true); |
function I(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function P(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&I(e)}else v= V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++R;else R=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(R)*500);S=setTimeout(function(){p()},c)}else p()}}function y(){C.abort();K=C=null;p()}function J(c,d,e,g){H&&c==H&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function j(){if(C!=null&&K!=null){clearTimeout(K); | function I(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function Q(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&I(e)}else v= V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++S;else S=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(S)*500);M=setTimeout(function(){p()},c)}else p()}}function y(){C.abort();K=C=null;p()}function J(c,d,e,g){H&&c==H&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function j(){if(C!=null&&K!=null){clearTimeout(K); | function I(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function P(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&I(e)}else v=V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++R;else R=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(R)*500);S=setTimeout(function(){p()},c)}else p()}}function y(){C.abort();K=C=null;p()}function J(c,d,e,g){H&&c==H&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function j(){if(C!=null&&K!=null){clearTimeout(K); |
"",d=false,e=0;e<y.length;++e){d=d||y[e].feedback;c+=y[e].data}ga=y;y=[];return{feedback:d,result:c}}function z(){R=true;if(aa){clearTimeout(aa);aa=null}var c=$("#Wt-timers");c.size()>0&&h.setHtml(c.get(0),"",false)}function P(){h.history._initTimeout();ba==0&&u(null,"none",null,false);aa=setTimeout(P,_$_KEEP_ALIVE_$_000)}function da(c){if(!h.isIEMobile)document.title=c}function a(){if(!document.activeElement){function c(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function d(){document.activeElement= null}document.addEventListener("focus",c,true);document.addEventListener("blur",d,true)}h.history._initialize();U();if(!ja){ja=true;_$_ONLOAD_$_();R||(aa=setTimeout(P,_$_KEEP_ALIVE_$_000))}}function b(c){clearTimeout(c);document.body.style.cursor="auto";if(ea!=null){try{ea()}catch(d){}ea=null}}function f(){document.body.style.cursor="wait";ea=hideLoadingIndicator;showLoadingIndicator()}function l(c){ka=c}function n(c){if(c){c="(function() {"+c+"})();";window.execScript?window.execScript(c):window.eval(c)}k._p_.autoJavaScript()} | e.target==document?null:e.target}function d(){document.activeElement=null}document.addEventListener("focus",c,true);document.addEventListener("blur",d,true)}h.history._initialize();U();if(!ja){ja=true;_$_ONLOAD_$_();R||(aa=setTimeout(z,_$_KEEP_ALIVE_$_000))}}function b(c){clearTimeout(c);document.body.style.cursor="auto";if(ea!=null){try{ea()}catch(d){}ea=null}}function f(){document.body.style.cursor="wait";ea=hideLoadingIndicator;showLoadingIndicator()}function l(c){ka=c}function n(c){if(c){c="(function() {"+ | "",d=false,e=0;e<y.length;++e){d=d||y[e].feedback;c+=y[e].data}ga=y;y=[];return{feedback:d,result:c}}function z(){R=true;if(aa){clearTimeout(aa);aa=null}var c=$("#Wt-timers");c.size()>0&&h.setHtml(c.get(0),"",false)}function P(){h.history._initTimeout();ba==0&&u(null,"none",null,false);aa=setTimeout(P,_$_KEEP_ALIVE_$_000)}function da(c){if(!h.isIEMobile)document.title=c}function a(){if(!document.activeElement){function c(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function d(){document.activeElement=null}document.addEventListener("focus",c,true);document.addEventListener("blur",d,true)}h.history._initialize();U();if(!ja){ja=true;_$_ONLOAD_$_();R||(aa=setTimeout(P,_$_KEEP_ALIVE_$_000))}}function b(c){clearTimeout(c);document.body.style.cursor="auto";if(ea!=null){try{ea()}catch(d){}ea=null}}function f(){document.body.style.cursor="wait";ea=hideLoadingIndicator;showLoadingIndicator()}function l(c){ka=c}function n(c){if(c){c="(function() {"+c+"})();";window.execScript?window.execScript(c):window.eval(c)}k._p_.autoJavaScript()} |
p.onreadystatechange=function(){var t=p.readyState;if(t=="loaded")h.isOpera?M(c):j();else t=="complete"&&M(c)};document.getElementsByTagName("head")[0].appendChild(p)}}function x(c,d){this.callback=d;this.work=c.length;this.images=[];if(c.length==0)d(this.images);else for(d=0;d<c.length;d++)this.preload(c[d])}function D(c){if(c.ieAlternativeExecuted)return"0";k.emit(c.parentNode,"IeAltnernative");c.style.width="";c.ieAlternativeExecuted=true;return"0"}function Y(c){window.onbeforeunload=c&&c!=""? | p.setAttribute("src",c);p.onload=function(){M(c)};p.onerror=j;p.onreadystatechange=function(){var t=p.readyState;if(t=="loaded")h.isOpera?M(c):j();else t=="complete"&&M(c)};document.getElementsByTagName("head")[0].appendChild(p)}}function x(c,d){this.callback=d;this.work=c.length;this.images=[];if(c.length==0)d(this.images);else for(d=0;d<c.length;d++)this.preload(c[d])}function D(c){if(c.ieAlternativeExecuted)return"0";k.emit(c.parentNode,"IeAltnernative");c.style.width="";c.ieAlternativeExecuted= true;return"0"}function Y(c){window.onbeforeunload=c&&c!=""?function(d){if(d=d||window.event)d.returnValue=c;return c}:null}var k=this,h=_$_WT_CLASS_$_,s=0,A=0,H=null,E={object:null,sourceId:null,mimeType:null,dropOffsetX:null,dragOffsetY:null,dropTarget:null,objectPrevStyle:null,xy:null},Z=_$_FORM_OBJECTS_$_;h.button=function(c){return c.which?c.which==3?4:c.which==2?2:1:h.isIE&&typeof c.button!="undefined"?c.button==2?4:c.button==4?2:1:typeof c.button!="undefined"?c.button==2?4:c.button==1?2:1: | p.onreadystatechange=function(){var t=p.readyState;if(t=="loaded")h.isOpera?M(c):j();else t=="complete"&&M(c)};document.getElementsByTagName("head")[0].appendChild(p)}}function x(c,d){this.callback=d;this.work=c.length;this.images=[];if(c.length==0)d(this.images);else for(d=0;d<c.length;d++)this.preload(c[d])}function D(c){if(c.ieAlternativeExecuted)return"0";k.emit(c.parentNode,"IeAltnernative");c.style.width="";c.ieAlternativeExecuted=true;return"0"}function Y(c){window.onbeforeunload=c&&c!=""? |
"paddingTop"),w=a.pxself(q.rows[q.rows.length-1].childNodes[0],"paddingBottom");new a.SizeHandle(a,"h",u.offsetWidth,q.offsetHeight-v-w,n,r,"Wt-hsh",function(B){k(e,j,B)},u,l,m,0,-e.offsetTop+v-a.pxself(e,"paddingTop"))}function d(e,j,m){var n=e.parentNode.previousSibling;e=e.parentNode.nextSibling;var r=n.offsetHeight,u=e.offsetHeight;if(h.stretch[j]>0&&h.stretch[j+1]>0)h.stretch[j]=-1;if(h.stretch[j+1]==0)h.stretch[j+1]=-1;h.stretch[j]<=0&&g.adjustRow(n,r+m);h.stretch[j+1]<=0&&g.adjustRow(e,u-m); a.getElement(t).dirty=true;window.onresize()}function i(){var e,j=0;for(e=0;;++e){var m=p(e);if(m)j+=a.pctself(m,"width");else break}if(j!=0)for(e=0;;++e)if(m=p(e)){var n=a.pctself(m,"width");if(n)m.style.width=n*100/j+"%"}else break}function k(e,j,m){e=p(j);var n=o(e,j),r=p(j+1),u=o(r,j+1);if(a.pctself(e,"width")>0&&a.pctself(r,"width")>0){e.style.width="";i()}a.pctself(e,"width")==0&&b(j,n+m);a.pctself(r,"width")==0&&b(j+1,u-m);window.onresize()}var g=this,p=g.getColumn,l=a.getElement(t);if(l)if(!g.resizeInitialized){var q= | a.getElement(t).dirty=true;window.onresize()}function d(){var e,j=0;for(e=0;;++e){var m=p(e);if(m)j+=a.pctself(m,"width");else break}if(j!=0)for(e=0;;++e)if(m=p(e)){var n=a.pctself(m,"width");if(n)m.style.width=n*100/j+"%"}else break}function k(e,j,m){e=p(j);var n=o(e,j),r=p(j+1),u=o(r,j+1);if(a.pctself(e,"width")>0&&a.pctself(r,"width")>0){e.style.width="";d()}a.pctself(e,"width")==0&&b(j,n+m);a.pctself(r,"width")==0&&b(j+1,u-m);window.onresize()}var g=this,p=g.getColumn,l=a.getElement(t);if(l)if(!g.resizeInitialized){var s= | "paddingTop"),w=a.pxself(q.rows[q.rows.length-1].childNodes[0],"paddingBottom");new a.SizeHandle(a,"h",u.offsetWidth,q.offsetHeight-v-w,n,r,"Wt-hsh",function(B){k(e,j,B)},u,l,m,0,-e.offsetTop+v-a.pxself(e,"paddingTop"))}function d(e,j,m){var n=e.parentNode.previousSibling;e=e.parentNode.nextSibling;var r=n.offsetHeight,u=e.offsetHeight;if(h.stretch[j]>0&&h.stretch[j+1]>0)h.stretch[j]=-1;if(h.stretch[j+1]==0)h.stretch[j+1]=-1;h.stretch[j]<=0&&g.adjustRow(n,r+m);h.stretch[j+1]<=0&&g.adjustRow(e,u-m);a.getElement(t).dirty=true;window.onresize()}function i(){var e,j=0;for(e=0;;++e){var m=p(e);if(m)j+=a.pctself(m,"width");else break}if(j!=0)for(e=0;;++e)if(m=p(e)){var n=a.pctself(m,"width");if(n)m.style.width=n*100/j+"%"}else break}function k(e,j,m){e=p(j);var n=o(e,j),r=p(j+1),u=o(r,j+1);if(a.pctself(e,"width")>0&&a.pctself(r,"width")>0){e.style.width="";i()}a.pctself(e,"width")==0&&b(j,n+m);a.pctself(r,"width")==0&&b(j+1,u-m);window.onresize()}var g=this,p=g.getColumn,l=a.getElement(t);if(l)if(!g.resizeInitialized){var q= |
f,g){var h=c.parentNode.previousSibling;c=c.parentNode.nextSibling;var o=h.offsetHeight,q=c.offsetHeight;if(r.stretch[f]>0&&r.stretch[f+1]>0)r.stretch[f]=-1;if(r.stretch[f+1]==0)r.stretch[f+1]=-1;r.stretch[f]<=0&&p.adjustRow(h,o+g);r.stretch[f+1]<=0&&p.adjustRow(c,q-g);a.getElement(s).dirty=true;window.onresize()}function d(){var c,f=0;for(c=0;;++c){var g=u(c);if(g)f+=a.pctself(g,"width");else break}if(f!=0)for(c=0;;++c)if(g=u(c)){var h=a.pctself(g,"width");if(h)g.style.width=h*100/f+"%"}else break} | f,g){var j=c.parentNode.previousSibling;c=c.parentNode.nextSibling;var q=j.offsetHeight,s=c.offsetHeight;if(h.stretch[f]>0&&h.stretch[f+1]>0)h.stretch[f]=-1;if(h.stretch[f+1]==0)h.stretch[f+1]=-1;h.stretch[f]<=0&&r.adjustRow(j,q+g);h.stretch[f+1]<=0&&r.adjustRow(c,s-g);a.getElement(u).dirty=true;window.onresize()}function d(){var c,f=0;for(c=0;;++c){var g=t(c);if(g)f+=a.pctself(g,"width");else break}if(f!=0)for(c=0;;++c)if(g=t(c)){var j=a.pctself(g,"width");if(j)g.style.width=j*100/f+"%"}else break} | f,g){var h=c.parentNode.previousSibling;c=c.parentNode.nextSibling;var o=h.offsetHeight,q=c.offsetHeight;if(r.stretch[f]>0&&r.stretch[f+1]>0)r.stretch[f]=-1;if(r.stretch[f+1]==0)r.stretch[f+1]=-1;r.stretch[f]<=0&&p.adjustRow(h,o+g);r.stretch[f+1]<=0&&p.adjustRow(c,q-g);a.getElement(s).dirty=true;window.onresize()}function d(){var c,f=0;for(c=0;;++c){var g=u(c);if(g)f+=a.pctself(g,"width");else break}if(f!=0)for(c=0;;++c)if(g=u(c)){var h=a.pctself(g,"width");if(h)g.style.width=h*100/f+"%"}else break} |
V=setTimeout(e,_$_KEEP_ALIVE_$_000)}function k(d){if(!o.isIEMobile)document.title=d}function i(){if(!document.activeElement){function d(f){if(f&&f.target)document.activeElement=f.target==document?null:f.target}function c(){document.activeElement=null}document.addEventListener("focus",d,true);document.addEventListener("blur",c,true)}o.history._initialize();ba();if(!fa){fa=true;_$_ONLOAD_$_();Q||(V=setTimeout(e,_$_KEEP_ALIVE_$_000))}}function n(d){clearTimeout(d);document.body.style.cursor="auto";if(aa!= | c+"metaKey=1";if(k.shiftKey)f+=c+"shiftKey=1";d.data=f;return d}function a(){for(var d="",c=false,f=0;f<y.length;++f){c=c||y[f].feedback;d+=y[f].data}ba=y;y=[];return{feedback:c,result:d}}function b(){P=true;if(V){clearTimeout(V);V=null}var d=$("#Wt-timers");d.size()>0&&o.setHtml(d.get(0),"",false)}function e(){o.history._initTimeout();W==0&&z(null,"none",null,false);V=setTimeout(e,_$_KEEP_ALIVE_$_000)}function j(d){if(!o.isIEMobile)document.title=d}function i(){if(!document.activeElement){function d(f){if(f&& f.target)document.activeElement=f.target==document?null:f.target}function c(){document.activeElement=null}document.addEventListener("focus",d,true);document.addEventListener("blur",c,true)}o.history._initialize();aa();if(!fa){fa=true;_$_ONLOAD_$_();P||(V=setTimeout(e,_$_KEEP_ALIVE_$_000))}}function n(d){clearTimeout(d);document.body.style.cursor="auto";if(Z!=null){try{Z()}catch(c){}Z=null}}function J(){document.body.style.cursor="wait";Z=hideLoadingIndicator;showLoadingIndicator()}function u(d){ga= | V=setTimeout(e,_$_KEEP_ALIVE_$_000)}function k(d){if(!o.isIEMobile)document.title=d}function i(){if(!document.activeElement){function d(f){if(f&&f.target)document.activeElement=f.target==document?null:f.target}function c(){document.activeElement=null}document.addEventListener("focus",d,true);document.addEventListener("blur",c,true)}o.history._initialize();ba();if(!fa){fa=true;_$_ONLOAD_$_();Q||(V=setTimeout(e,_$_KEEP_ALIVE_$_000))}}function n(d){clearTimeout(d);document.body.style.cursor="auto";if(aa!= |
null){try{aa()}catch(c){}aa=null}}function K(){document.body.style.cursor="wait";aa=hideLoadingIndicator;showLoadingIndicator()}function u(d){ga=d}function q(d){if(d)window.execScript?window.execScript(d):window.eval(d);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(d,c,f){if(!Q){if(d==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();q(c);_$_$ifnot_DEBUG_$_()}catch(j){alert("Wt internal error: "+j+", code: "+j.code+", description: "+j.description)}_$_$endif_$_();f&&n(f)}else z=ca.concat(z);ca=[];if(O){clearTimeout(O); O=null}J=null;if(d>0)++W;else W=0;if(!Q)if(ga||z.length>0)if(d==1){d=Math.min(12E4,Math.exp(W)*500);R=setTimeout(function(){G()},d)}else G()}}function x(){J.abort();O=J=null;Q||G()}function A(d,c,f,j){o.checkReleaseCapture(d,f);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var m={},g=z.length;m.object=d;m.signal=c;m.event=f;m.feedback=j;z[g]=T(m,g);F();q();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function F(){if(J!=null&&O!=null){clearTimeout(O);J.abort();J=null}if(J== | setTimeout(m.tm,c);else{m.timer=null;m.tm=null}m.onclick&&m.onclick()}},h=o.getElement(d);h.timer=setTimeout(k,c);h.tm=k}function D(d,c){setTimeout(function(){if(R[d]===true)c();else R[d]=c},20)}function M(d){if(R[d]!==true){typeof R[d]!=="undefined"&&R[d]();R[d]=true}}function l(d,c){var f=false;if(c!="")try{f=!eval("typeof "+c+" === 'undefined'")}catch(k){f=false}if(f)M(d);else{var h=document.createElement("script");h.setAttribute("src",d);h.onload=function(){M(d)};h.onreadystatechange=function(){if(h.readyState== | null){try{aa()}catch(c){}aa=null}}function K(){document.body.style.cursor="wait";aa=hideLoadingIndicator;showLoadingIndicator()}function u(d){ga=d}function q(d){if(d)window.execScript?window.execScript(d):window.eval(d);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(d,c,f){if(!Q){if(d==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();q(c);_$_$ifnot_DEBUG_$_()}catch(j){alert("Wt internal error: "+j+", code: "+j.code+", description: "+j.description)}_$_$endif_$_();f&&n(f)}else z=ca.concat(z);ca=[];if(O){clearTimeout(O);O=null}J=null;if(d>0)++W;else W=0;if(!Q)if(ga||z.length>0)if(d==1){d=Math.min(12E4,Math.exp(W)*500);R=setTimeout(function(){G()},d)}else G()}}function x(){J.abort();O=J=null;Q||G()}function A(d,c,f,j){o.checkReleaseCapture(d,f);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var m={},g=z.length;m.object=d;m.signal=c;m.event=f;m.feedback=j;z[g]=T(m,g);F();q();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function F(){if(J!=null&&O!=null){clearTimeout(O);J.abort();J=null}if(J== |
d)}else G()}}function x(){J.abort();O=J=null;Q||G()}function A(d,c,f,j){o.checkReleaseCapture(d,f);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var m={},h=z.length;m.object=d;m.signal=c;m.event=f;m.feedback=j;z[h]=T(m,h);F();q();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function F(){if(J!=null&&O!=null){clearTimeout(O);J.abort();J=null}if(J==null)if(R==null){R=setTimeout(function(){G()},o.updateDelay);ha=(new Date).getTime()}else if(W){clearTimeout(R);G()}else if((new Date).getTime()- | d)}else G()}}function x(){J.abort();O=J=null;Q||G()}function A(d,c,f,j){o.checkReleaseCapture(d,f);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var m={},g=z.length;m.object=d;m.signal=c;m.event=f;m.feedback=j;z[g]=T(m,g);F();q();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function F(){if(J!=null&&O!=null){clearTimeout(O);J.abort();J=null}if(J==null)if(R==null){R=setTimeout(function(){G()},o.updateDelay);ha=(new Date).getTime()}else if(W){clearTimeout(R);G()}else if((new Date).getTime()- | d}function q(d){if(d)window.execScript?window.execScript(d):window.eval(d);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(d,c,f){if(!Q){if(d==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();q(c);_$_$ifnot_DEBUG_$_()}catch(j){alert("Wt internal error: "+j+", code: "+j.code+", description: "+j.description)}_$_$endif_$_();f&&n(f)}else z=ca.concat(z);ca=[];if(O){clearTimeout(O);O=null}J=null;if(d>0)++W;else W=0;if(!Q)if(ga||z.length>0)if(d==1){d=Math.min(12E4,Math.exp(W)*500);R=setTimeout(function(){G()},d)}else G()}}function x(){J.abort();O=J=null;Q||G()}function A(d,c,f,j){o.checkReleaseCapture(d,f);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var m={},h=z.length;m.object=d;m.signal=c;m.event=f;m.feedback=j;z[h]=T(m,h);F();q();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function F(){if(J!=null&&O!=null){clearTimeout(O);J.abort();J=null}if(J==null)if(R==null){R=setTimeout(function(){G()},o.updateDelay);ha=(new Date).getTime()}else if(W){clearTimeout(R);G()}else if((new Date).getTime()- |
d+=A[e].data}da=A;A=[];return{feedback:c,result:d}}function Y(){P=true;if(W){clearTimeout(W);W=null}var d=$("#Wt-timers");d.size()>0&&n.setHtml(d.get(0),"",false)}function a(){n.history._initTimeout();X==0&&y(null,"none",null,false);W=setTimeout(a,_$_KEEP_ALIVE_$_000)}function b(d){if(!n.isIEMobile)document.title=d}function f(){if(!document.activeElement){function d(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function c(){document.activeElement=null}document.addEventListener("focus", | c+"shiftKey=1";d.data=e;return d}function S(){for(var d="",c=false,e=0;e<A.length;++e){c=c||A[e].feedback;d+=A[e].data}da=A;A=[];return{feedback:c,result:d}}function Y(){P=true;if(W){clearTimeout(W);W=null}var d=$("#Wt-timers");d.size()>0&&n.setHtml(d.get(0),"",false)}function a(){n.history._initTimeout();X==0&&y(null,"none",null,false);W=setTimeout(a,_$_KEEP_ALIVE_$_000)}function b(d){if(!n.isIEMobile)document.title=d}function f(){if(!document.activeElement){function d(e){if(e&&e.target)document.activeElement= e.target==document?null:e.target}function c(){document.activeElement=null}document.addEventListener("focus",d,true);document.addEventListener("blur",c,true)}n.history._initialize();T();if(!ga){ga=true;_$_ONLOAD_$_();P||(W=setTimeout(a,_$_KEEP_ALIVE_$_000))}}function h(d){clearTimeout(d);document.body.style.cursor="auto";if(ba!=null){try{ba()}catch(c){}ba=null}}function k(){document.body.style.cursor="wait";ba=hideLoadingIndicator;showLoadingIndicator()}function o(d){ha=d}function E(d){if(d){d="(function() {"+ | d+=A[e].data}da=A;A=[];return{feedback:c,result:d}}function Y(){P=true;if(W){clearTimeout(W);W=null}var d=$("#Wt-timers");d.size()>0&&n.setHtml(d.get(0),"",false)}function a(){n.history._initTimeout();X==0&&y(null,"none",null,false);W=setTimeout(a,_$_KEEP_ALIVE_$_000)}function b(d){if(!n.isIEMobile)document.title=d}function f(){if(!document.activeElement){function d(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function c(){document.activeElement=null}document.addEventListener("focus", |
null}}function r(){document.body.style.cursor="wait";X=hideLoadingIndicator;showLoadingIndicator()}function t(d){ea=d}function C(d){if(d)if(window.execScript)window.execScript(d);else with(window)eval(d);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(d,c,e){if(!ba){if(d==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();C(c);_$_$ifnot_DEBUG_$_()}catch(h){alert("Wt internal error: "+h+", code: "+h.code+", description: "+h.description)}_$_$endif_$_();e&&B(e)}else x=Z.concat(x);Z=[];if(L){clearTimeout(L); L=null}J=null;if(d>0)++U;else U=0;if(ea||x.length>0)if(d==1){d=Math.min(12E4,Math.exp(U)*500);N=setTimeout(function(){A()},d)}else A()}}function K(){J.abort();L=J=null;A()}function H(d,c,e,h){n.checkReleaseCapture(d,e);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var i={},j=x.length;i.object=d;i.signal=c;i.event=e;i.feedback=h;x[j]=b(i,j);E();C();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function E(){if(J!=null&&L!=null){clearTimeout(L);J.abort();J=null}if(J==null)if(N== | h);j=j.substring(h,r);if(j.length!=0){c.dropTarget.setAttribute("dos",c.dropTarget.className);c.dropTarget.className=c.dropTarget.className+" "+j}}else c.object.styleClass="";if(e!=null){e.handleDragDrop&&e.handleDragDrop("end",c.object,d,"",i);j=e.getAttribute("dos");if(j!=null)e.className=j}}if(c.dropTarget)if(c.dropTarget.handleDragDrop)c.dropTarget.handleDragDrop("drag",c.object,d,"",i);else c.object.className="Wt-valid-drop";g.cancelEvent(d);return false}return true}function D(d){g.capture(null); var c=J;if(c.object){if(c.dropTarget){var e=c.dropTarget.getAttribute("dos");if(e!=null)c.dropTarget.className=e;c.dropTarget.handleDragDrop?c.dropTarget.handleDragDrop("drop",c.object,d,c.sourceId,c.mimeType):O(c.dropTarget,{name:"_drop",eventObject:c.dropTarget,event:d},c.sourceId,c.mimeType)}c.object.style.position=c.objectPrevStyle.position;c.object.style.display=c.objectPrevStyle.display;c.object.style.left=c.objectPrevStyle.left;c.object.style.top=c.objectPrevStyle.top;c.object.className=c.objectPrevStyle.className; c.object=null}}function R(d,c){var e,h;h=d.event;c=c>0?"&e"+c:"&";e=c+"signal="+d.signal;if(d.id){e+=c+"id="+d.id+c+"name="+encodeURIComponent(d.name)+c+"an="+d.args.length;for(var i=0;i<d.args.length;++i)e+=c+"a"+i+"="+encodeURIComponent(d.args[i])}for(var j=0;j<B.length;++j){var r=g.getElement(B[j]),v=null,W;if(r!=null){if(r.type=="select-multiple"){i=0;for(W=r.options.length;i<W;i++)if(r.options[i].selected)e+=c+B[j]+"="+encodeURIComponent(r.options[i].value)}else if(g.hasTag(r,"SPAN")){i=0;for(W= | null}}function r(){document.body.style.cursor="wait";X=hideLoadingIndicator;showLoadingIndicator()}function t(d){ea=d}function C(d){if(d)if(window.execScript)window.execScript(d);else with(window)eval(d);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(d,c,e){if(!ba){if(d==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();C(c);_$_$ifnot_DEBUG_$_()}catch(h){alert("Wt internal error: "+h+", code: "+h.code+", description: "+h.description)}_$_$endif_$_();e&&B(e)}else x=Z.concat(x);Z=[];if(L){clearTimeout(L);L=null}J=null;if(d>0)++U;else U=0;if(ea||x.length>0)if(d==1){d=Math.min(12E4,Math.exp(U)*500);N=setTimeout(function(){A()},d)}else A()}}function K(){J.abort();L=J=null;A()}function H(d,c,e,h){n.checkReleaseCapture(d,e);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!J){_$_$endif_$_();var i={},j=x.length;i.object=d;i.signal=c;i.event=e;i.feedback=h;x[j]=b(i,j);E();C();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function E(){if(J!=null&&L!=null){clearTimeout(L);J.abort();J=null}if(J==null)if(N== |
function H(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function Q(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&H(e)}else v= V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++S;else S=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(S)*500);M=setTimeout(function(){q()},c)}else q()}}function y(){C.abort();K=C=null;q()}function I(c,d,e,g){J&&c==J&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function j(){if(C!=null&&K!=null){clearTimeout(K); | function H(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function Q(c){ca=c}function E(c){if(c)if(window.execScript)window.execScript(c);else with(window)eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+ g.description)}_$_$endif_$_();e&&H(e)}else v=V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++S;else S=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(S)*500);M=setTimeout(function(){q()},c)}else q()}}function y(){C.abort();K=C=null;q()}function I(c,d,e,g){J&&c==J&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()} | function H(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function Q(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&H(e)}else v=V.concat(v);V=[];if(K){clearTimeout(K);K=null}C=null;if(c>0)++S;else S=0;if(ca||v.length>0)if(c==1){c=Math.min(12E4,Math.exp(S)*500);M=setTimeout(function(){q()},c)}else q()}}function y(){C.abort();K=C=null;q()}function I(c,d,e,g){J&&c==J&&e.type=="mouseup"&&f(null);_$_$if_STRICTLY_SERIALIZED_EVENTS_$_();if(!C){_$_$endif_$_();var h={},i=v.length;h.object=c;h.signal=d;h.event=e;h.feedback=g;v[i]=r(h,i);j();E();_$_$if_STRICTLY_SERIALIZED_EVENTS_$_()}_$_$endif_$_()}function j(){if(C!=null&&K!=null){clearTimeout(K); |
if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);S=M+Q;var T=new h(K.$.rows[S]),U=z(L,S),V;P=I.clone();for(var W=0;W<U.length;W++){V=U[W];if(V.parentNode==T.$&&W>N){P.insertBefore(new h(V));break;}else V=null;}if(!V)T.append(P,true);}else{R=Q=1;T=J.clone();T.insertAfter(J);T.append(P=I.clone());var X=z(L,M);for(var Y=0;Y<X.length;Y++)X[Y].rowSpan++;}if(!c)P.appendBogus();I.$.rowSpan=Q;P.$.rowSpan=R;if(Q==1)I.removeAttribute('rowSpan');if(R==1)P.removeAttribute('rowSpan');return P;};function D(F,G){var H=n(F);if(H.length>1)return false;else if(G)return true;var I=H[0],J=I.getParent(),K=J.getAscendant('table'),L=y(K),M=J.$.rowIndex,N=z(L,M,I),O=I.$.colSpan,P,Q,R;if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);}else{R=Q=1;var S=A(L,N);for(var T=0;T<S.length;T++)S[T].colSpan++;}P=I.clone();P.insertAfter(I);if(!c)P.appendBogus();I.$.colSpan=Q;P.$.colSpan=R;if(Q==1)I.removeAttribute('colSpan');if(R==1)P.removeAttribute('colSpan');return P;};var E={thead:1,tbody:1,tfoot:1,td:1,tr:1,th:1};j.tabletools={init:function(F){var G=F.lang.table;F.addCommand('cellProperties',new a.dialogCommand('cellProperties'));a.dialog.add('cellProperties',this.path+'dialogs/tableCell.js');F.addCommand('tableDelete',{exec:function(H){var I=H.getSelection(),J=I&&I.getStartElement(),K=J&&J.getAscendant('table',true);if(!K)return;I.selectElement(K);var L=I.getRanges()[0];L.collapse();I.selectRanges([L]);if(K.getParent().getChildCount()==1)K.getParent().remove();else K.remove();}});F.addCommand('rowDelete',{exec:function(H){var I=H.getSelection();x(r(I));}});F.addCommand('rowInsertBefore',{exec:function(H){var I=H.getSelection();q(I,true);}});F.addCommand('rowInsertAfter',{exec:function(H){var I=H.getSelection();q(I);}});F.addCommand('columnDelete',{exec:function(H){var I=H.getSelection();t(I);}});F.addCommand('columnInsertBefore',{exec:function(H){var I=H.getSelection();s(I,true);}});F.addCommand('columnInsertAfter',{exec:function(H){var I=H.getSelection();s(I);}});F.addCommand('cellDelete',{exec:function(H){var I=H.getSelection();v(I);}});F.addCommand('cellMerge',{exec:function(H){x(B(H.getSelection()),true);}});F.addCommand('cellMergeRight',{exec:function(H){x(B(H.getSelection(),'right'),true);}});F.addCommand('cellMergeDown',{exec:function(H){x(B(H.getSelection(),'down'),true);}});F.addCommand('cellVerticalSplit',{exec:function(H){x(C(H.getSelection()));}});F.addCommand('cellHorizontalSplit',{exec:function(H){x(D(H.getSelection()));}});F.addCommand('cellInsertBefore',{exec:function(H){var I=H.getSelection(); | J<F.length;J++){var K=F[J];if(typeof H=='undefined')I.push(K[G]);else if(H.is&&K[G]==H.$)return J;else if(J==H)return new h(K[G]);}return typeof H=='undefined'?I:H.is?-1:null;};function B(F,G,H){var I=n(F),J;if((G?I.length!=1:I.length<2)||(J=F.getCommonAncestor())&&J.type==1&&J.is('table'))return false;var K,L=I[0],M=L.getAscendant('table'),N=e.buildTableMap(M),O=N.length,P=N[0].length,Q=L.getParent().$.rowIndex,R=z(N,Q,L);if(G){var S;try{S=N[G=='up'?Q-1:G=='down'?Q+1:Q][G=='left'?R-1:G=='right'?R+1:R];}catch(ak){return false;}if(!S||L.$==S)return false;I[G=='up'||G=='left'?'unshift':'push'](new h(S));}var T=L.getDocument(),U=Q,V=0,W=0,X=!H&&new d.documentFragment(T),Y=0;for(var Z=0;Z<I.length;Z++){K=I[Z];var aa=K.getParent(),ab=K.getFirst(),ac=K.$.colSpan,ad=K.$.rowSpan,ae=aa.$.rowIndex,af=z(N,ae,K);Y+=ac*ad;W=Math.max(W,af-R+ac);V=Math.max(V,ae-Q+ad);if(!H){if(x(K),K.getChildren().count()){if(ae!=U&&ab&&!(ab.isBlockBoundary&&ab.isBlockBoundary({br:1}))){var ag=X.getLast(d.walker.whitespaces(true));if(ag&&!(ag.is&&ag.is('br')))X.append(new h('br'));}K.moveChildren(X);}Z?K.remove():K.setHtml('');}U=ae;}if(!H){X.moveChildren(L);if(!c)L.appendBogus();if(W>=P)L.removeAttribute('rowSpan');else L.$.rowSpan=V;if(V>=O)L.removeAttribute('colSpan');else L.$.colSpan=W;var ah=new d.nodeList(M.$.rows),ai=ah.count();for(Z=ai-1;Z>=0;Z--){var aj=ah.getItem(Z);if(!aj.$.cells.length){aj.remove();ai++;continue;}}return L;}else return V*W==Y;};function C(F,G){var H=n(F);if(H.length>1)return false;else if(G)return true;var I=H[0],J=I.getParent(),K=J.getAscendant('table'),L=e.buildTableMap(K),M=J.$.rowIndex,N=z(L,M,I),O=I.$.rowSpan,P,Q,R,S;if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);S=M+Q;var T=new h(K.$.rows[S]),U=z(L,S),V;P=I.clone();for(var W=0;W<U.length;W++){V=U[W];if(V.parentNode==T.$&&W>N){P.insertBefore(new h(V));break;}else V=null;}if(!V)T.append(P,true);}else{R=Q=1;T=J.clone();T.insertAfter(J);T.append(P=I.clone());var X=z(L,M);for(var Y=0;Y<X.length;Y++)X[Y].rowSpan++;}if(!c)P.appendBogus();I.$.rowSpan=Q;P.$.rowSpan=R;if(Q==1)I.removeAttribute('rowSpan');if(R==1)P.removeAttribute('rowSpan');return P;};function D(F,G){var H=n(F);if(H.length>1)return false;else if(G)return true;var I=H[0],J=I.getParent(),K=J.getAscendant('table'),L=e.buildTableMap(K),M=J.$.rowIndex,N=z(L,M,I),O=I.$.colSpan,P,Q,R;if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);}else{R=Q=1;var S=A(L,N);for(var T=0;T<S.length;T++)S[T].colSpan++;}P=I.clone();P.insertAfter(I);if(!c)P.appendBogus();I.$.colSpan=Q;P.$.colSpan=R; if(Q==1)I.removeAttribute('colSpan');if(R==1)P.removeAttribute('colSpan');return P;};var E={thead:1,tbody:1,tfoot:1,td:1,tr:1,th:1};j.tabletools={init:function(F){var G=F.lang.table;F.addCommand('cellProperties',new a.dialogCommand('cellProperties'));a.dialog.add('cellProperties',this.path+'dialogs/tableCell.js');F.addCommand('tableDelete',{exec:function(H){var I=H.getSelection(),J=I&&I.getStartElement(),K=J&&J.getAscendant('table',true);if(!K)return;I.selectElement(K);var L=I.getRanges()[0];L.collapse();I.selectRanges([L]);var M=K.getParent();if(M.getChildCount()==1&&M.getName()!='body')M.remove();else K.remove();}});F.addCommand('rowDelete',{exec:function(H){var I=H.getSelection();y(r(I));}});F.addCommand('rowInsertBefore',{exec:function(H){var I=H.getSelection();q(I,true);}});F.addCommand('rowInsertAfter',{exec:function(H){var I=H.getSelection();q(I);}});F.addCommand('columnDelete',{exec:function(H){var I=H.getSelection(),J=u(I);J&&y(J,true);}});F.addCommand('columnInsertBefore',{exec:function(H){var I=H.getSelection();s(I,true);}});F.addCommand('columnInsertAfter',{exec:function(H){var I=H.getSelection();s(I);}});F.addCommand('cellDelete',{exec:function(H){var I=H.getSelection();w(I);}});F.addCommand('cellMerge',{exec:function(H){y(B(H.getSelection()),true);}});F.addCommand('cellMergeRight',{exec:function(H){y(B(H.getSelection(),'right'),true);}});F.addCommand('cellMergeDown',{exec:function(H){y(B(H.getSelection(),'down'),true);}});F.addCommand('cellVerticalSplit',{exec:function(H){y(C(H.getSelection()));}});F.addCommand('cellHorizontalSplit',{exec:function(H){y(D(H.getSelection()));}});F.addCommand('cellInsertBefore',{exec:function(H){var I=H.getSelection();v(I,true);}});F.addCommand('cellInsertAfter',{exec:function(H){var I=H.getSelection();v(I);}});if(F.addMenuItems)F.addMenuItems({tablecell:{label:G.cell.menu,group:'tablecell',order:1,getItems:function(){var H=F.getSelection(),I=n(H);return{tablecell_insertBefore:2,tablecell_insertAfter:2,tablecell_delete:2,tablecell_merge:B(H,null,true)?2:0,tablecell_merge_right:B(H,'right',true)?2:0,tablecell_merge_down:B(H,'down',true)?2:0,tablecell_split_vertical:C(H,true)?2:0,tablecell_split_horizontal:D(H,true)?2:0,tablecell_properties:I.length>0?2:0};}},tablecell_insertBefore:{label:G.cell.insertBefore,group:'tablecell',command:'cellInsertBefore',order:5},tablecell_insertAfter:{label:G.cell.insertAfter,group:'tablecell',command:'cellInsertAfter',order:10},tablecell_delete:{label:G.cell.deleteCell,group:'tablecell',command:'cellDelete',order:15},tablecell_merge:{label:G.cell.merge,group:'tablecell',command:'cellMerge',order:16},tablecell_merge_right:{label:G.cell.mergeRight,group:'tablecell',command:'cellMergeRight',order:17},tablecell_merge_down:{label:G.cell.mergeDown,group:'tablecell',command:'cellMergeDown',order:18},tablecell_split_horizontal:{label:G.cell.splitHorizontal,group:'tablecell',command:'cellHorizontalSplit',order:19},tablecell_split_vertical:{label:G.cell.splitVertical,group:'tablecell',command:'cellVerticalSplit',order:20},tablecell_properties:{label:G.cell.title,group:'tablecellproperties',command:'cellProperties',order:21},tablerow:{label:G.row.menu,group:'tablerow',order:1,getItems:function(){return{tablerow_insertBefore:2,tablerow_insertAfter:2,tablerow_delete:2}; | if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);S=M+Q;var T=new h(K.$.rows[S]),U=z(L,S),V;P=I.clone();for(var W=0;W<U.length;W++){V=U[W];if(V.parentNode==T.$&&W>N){P.insertBefore(new h(V));break;}else V=null;}if(!V)T.append(P,true);}else{R=Q=1;T=J.clone();T.insertAfter(J);T.append(P=I.clone());var X=z(L,M);for(var Y=0;Y<X.length;Y++)X[Y].rowSpan++;}if(!c)P.appendBogus();I.$.rowSpan=Q;P.$.rowSpan=R;if(Q==1)I.removeAttribute('rowSpan');if(R==1)P.removeAttribute('rowSpan');return P;};function D(F,G){var H=n(F);if(H.length>1)return false;else if(G)return true;var I=H[0],J=I.getParent(),K=J.getAscendant('table'),L=y(K),M=J.$.rowIndex,N=z(L,M,I),O=I.$.colSpan,P,Q,R;if(O>1){Q=Math.ceil(O/2);R=Math.floor(O/2);}else{R=Q=1;var S=A(L,N);for(var T=0;T<S.length;T++)S[T].colSpan++;}P=I.clone();P.insertAfter(I);if(!c)P.appendBogus();I.$.colSpan=Q;P.$.colSpan=R;if(Q==1)I.removeAttribute('colSpan');if(R==1)P.removeAttribute('colSpan');return P;};var E={thead:1,tbody:1,tfoot:1,td:1,tr:1,th:1};j.tabletools={init:function(F){var G=F.lang.table;F.addCommand('cellProperties',new a.dialogCommand('cellProperties'));a.dialog.add('cellProperties',this.path+'dialogs/tableCell.js');F.addCommand('tableDelete',{exec:function(H){var I=H.getSelection(),J=I&&I.getStartElement(),K=J&&J.getAscendant('table',true);if(!K)return;I.selectElement(K);var L=I.getRanges()[0];L.collapse();I.selectRanges([L]);if(K.getParent().getChildCount()==1)K.getParent().remove();else K.remove();}});F.addCommand('rowDelete',{exec:function(H){var I=H.getSelection();x(r(I));}});F.addCommand('rowInsertBefore',{exec:function(H){var I=H.getSelection();q(I,true);}});F.addCommand('rowInsertAfter',{exec:function(H){var I=H.getSelection();q(I);}});F.addCommand('columnDelete',{exec:function(H){var I=H.getSelection();t(I);}});F.addCommand('columnInsertBefore',{exec:function(H){var I=H.getSelection();s(I,true);}});F.addCommand('columnInsertAfter',{exec:function(H){var I=H.getSelection();s(I);}});F.addCommand('cellDelete',{exec:function(H){var I=H.getSelection();v(I);}});F.addCommand('cellMerge',{exec:function(H){x(B(H.getSelection()),true);}});F.addCommand('cellMergeRight',{exec:function(H){x(B(H.getSelection(),'right'),true);}});F.addCommand('cellMergeDown',{exec:function(H){x(B(H.getSelection(),'down'),true);}});F.addCommand('cellVerticalSplit',{exec:function(H){x(C(H.getSelection()));}});F.addCommand('cellHorizontalSplit',{exec:function(H){x(D(H.getSelection()));}});F.addCommand('cellInsertBefore',{exec:function(H){var I=H.getSelection(); |
"",d=false,e=0;e<y.length;++e){d=d||y[e].feedback;c+=y[e].data}ga=y;y=[];return{feedback:d,result:c}}function z(){R=true;if(aa){clearTimeout(aa);aa=null}var c=$("#Wt-timers");c.size()>0&&h.setHtml(c.get(0),"",false)}function P(){h.history._initTimeout();ba==0&&u(null,"none",null,false);aa=setTimeout(P,_$_KEEP_ALIVE_$_000)}function da(c){if(!h.isIEMobile)document.title=c}function a(){if(!document.activeElement){function c(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function d(){document.activeElement= | d+"rotation="+j.rotation;c.data=e;return c}function X(){for(var c="",d=false,e=0;e<y.length;++e){d=d||y[e].feedback;c+=y[e].data}ga=y;y=[];return{feedback:d,result:c}}function N(){R=true;if(aa){clearTimeout(aa);aa=null}var c=$("#Wt-timers");c.size()>0&&h.setHtml(c.get(0),"",false)}function z(){h.history._initTimeout();ba==0&&u(null,"none",null,false);aa=setTimeout(z,_$_KEEP_ALIVE_$_000)}function da(c){if(!h.isIEMobile)document.title=c}function a(){if(!document.activeElement){function c(e){if(e&&e.target)document.activeElement= | "",d=false,e=0;e<y.length;++e){d=d||y[e].feedback;c+=y[e].data}ga=y;y=[];return{feedback:d,result:c}}function z(){R=true;if(aa){clearTimeout(aa);aa=null}var c=$("#Wt-timers");c.size()>0&&h.setHtml(c.get(0),"",false)}function P(){h.history._initTimeout();ba==0&&u(null,"none",null,false);aa=setTimeout(P,_$_KEEP_ALIVE_$_000)}function da(c){if(!h.isIEMobile)document.title=c}function a(){if(!document.activeElement){function c(e){if(e&&e.target)document.activeElement=e.target==document?null:e.target}function d(){document.activeElement= |
!g)return null;g||(g=++za);if(typeof b==="object"){a[B]=g;h=h[g]=d.extend(true,{},b)}else h=h[g]?h[g]:typeof e==="undefined"?Aa:(h[g]={});if(e!==v){a[B]=g;h[b]=e}return typeof b==="string"?h[b]:h}},removeData:function(a,b){if(!(a.nodeName&&d.noData[a.nodeName.toLowerCase()])){a=a==x?da:a;var e=a[B],g=d.cache,h=g[e];if(b){if(h){delete h[b];d.isEmptyObject(h)&&d.removeData(a)}}else{try{delete a[B]}catch(k){a.removeAttribute&&a.removeAttribute(B)}delete g[e]}}}});d.fn.extend({data:function(a,b){if(typeof a=== "undefined"&&this.length)return d.data(this[0]);else if(typeof a==="object")return this.each(function(){d.data(this,a)});var e=a.split(".");e[1]=e[1]?"."+e[1]:"";if(b===v){var g=this.triggerHandler("getData"+e[1]+"!",[e[0]]);if(g===v&&this.length)g=d.data(this[0],a);return g===v&&e[1]?this.data(e[0]):g}else return this.trigger("setData"+e[1]+"!",[e[0],b]).each(function(){d.data(this,a,b)})},removeData:function(a){return this.each(function(){d.removeData(this,a)})}});(function(){function a(c){for(var f= | !f)return null;f||(f=++za);if(typeof b==="object"){a[B]=f;h=h[f]=c.extend(true,{},b)}else h=h[f]?h[f]:typeof e==="undefined"?Aa:(h[f]={});if(e!==v){a[B]=f;h[b]=e}return typeof b==="string"?h[b]:h}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==x?da:a;var e=a[B],f=c.cache,h=f[e];if(b){if(h){delete h[b];c.isEmptyObject(h)&&c.removeData(a)}}else{try{delete a[B]}catch(k){a.removeAttribute&&a.removeAttribute(B)}delete f[e]}}}});c.fn.extend({data:function(a,b){if(typeof a=== "undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var e=a.split(".");e[1]=e[1]?"."+e[1]:"";if(b===v){var f=this.triggerHandler("getData"+e[1]+"!",[e[0]]);if(f===v&&this.length)f=c.data(this[0],a);return f===v&&e[1]?this.data(e[0]):f}else return this.trigger("setData"+e[1]+"!",[e[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});(function(){function a(d){for(var g= | !g)return null;g||(g=++za);if(typeof b==="object"){a[B]=g;h=h[g]=d.extend(true,{},b)}else h=h[g]?h[g]:typeof e==="undefined"?Aa:(h[g]={});if(e!==v){a[B]=g;h[b]=e}return typeof b==="string"?h[b]:h}},removeData:function(a,b){if(!(a.nodeName&&d.noData[a.nodeName.toLowerCase()])){a=a==x?da:a;var e=a[B],g=d.cache,h=g[e];if(b){if(h){delete h[b];d.isEmptyObject(h)&&d.removeData(a)}}else{try{delete a[B]}catch(k){a.removeAttribute&&a.removeAttribute(B)}delete g[e]}}}});d.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return d.data(this[0]);else if(typeof a==="object")return this.each(function(){d.data(this,a)});var e=a.split(".");e[1]=e[1]?"."+e[1]:"";if(b===v){var g=this.triggerHandler("getData"+e[1]+"!",[e[0]]);if(g===v&&this.length)g=d.data(this[0],a);return g===v&&e[1]?this.data(e[0]):g}else return this.trigger("setData"+e[1]+"!",[e[0],b]).each(function(){d.data(this,a,b)})},removeData:function(a){return this.each(function(){d.removeData(this,a)})}});(function(){function a(c){for(var f= |
prevText: '{$lblPrevious}' | prevText: '{$lblPrevious}', showAnim: 'slideDown' | datefields: function() { // the default, nothing special if($('.inputDatefieldNormal').length > 0) { $('.inputDatefieldNormal').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}' }); }); } // datefields that have a certain startdate if($('.inputDatefieldFrom').length > 0) { $('.inputDatefieldFrom').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]) }); }); } // datefields that have a certain enddate if($('.inputDatefieldTill').length > 0) { $('.inputDatefieldTill').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]) }); }); } // datefields that have a certain range if($('.inputDatefieldRange').length > 0) { $('.inputDatefieldRange').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]), maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]) }); }); } }, |
minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]) | minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]), showAnim: 'slideDown' | datefields: function() { // the default, nothing special if($('.inputDatefieldNormal').length > 0) { $('.inputDatefieldNormal').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}' }); }); } // datefields that have a certain startdate if($('.inputDatefieldFrom').length > 0) { $('.inputDatefieldFrom').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]) }); }); } // datefields that have a certain enddate if($('.inputDatefieldTill').length > 0) { $('.inputDatefieldTill').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]) }); }); } // datefields that have a certain range if($('.inputDatefieldRange').length > 0) { $('.inputDatefieldRange').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]), maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]) }); }); } }, |
maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]) | maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]), showAnim: 'slideDown' | datefields: function() { // the default, nothing special if($('.inputDatefieldNormal').length > 0) { $('.inputDatefieldNormal').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}' }); }); } // datefields that have a certain startdate if($('.inputDatefieldFrom').length > 0) { $('.inputDatefieldFrom').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]) }); }); } // datefields that have a certain enddate if($('.inputDatefieldTill').length > 0) { $('.inputDatefieldTill').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]) }); }); } // datefields that have a certain range if($('.inputDatefieldRange').length > 0) { $('.inputDatefieldRange').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]), maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]) }); }); } }, |
maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]) | maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]), showAnim: 'slideDown' | datefields: function() { // the default, nothing special if($('.inputDatefieldNormal').length > 0) { $('.inputDatefieldNormal').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}' }); }); } // datefields that have a certain startdate if($('.inputDatefieldFrom').length > 0) { $('.inputDatefieldFrom').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]) }); }); } // datefields that have a certain enddate if($('.inputDatefieldTill').length > 0) { $('.inputDatefieldTill').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', maxDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) -1, data[2].split('-')[2]) }); }); } // datefields that have a certain range if($('.inputDatefieldRange').length > 0) { $('.inputDatefieldRange').each(function() { var data = $(this).attr('rel').split(':::'); $(this).datepicker({ dateFormat: data[0], dayNames: ['{$locDayLongMon}', '{$locDayLongTue}', '{$locDayLongWed}', '{$locDayLongThu}', '{$locDayLongFri}', '{$locDayLongSat}', '{$locDayLongSat}'], dayNamesMin: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], dayNamesShort: ['{$locDayShortMon}', '{$locDayShortTue}', '{$locDayShortWed}', '{$locDayShortThu}', '{$locDayShortFri}', '{$locDayShortSat}', '{$locDayShortSat}'], firstDay: data[1], hideIfNoPrevNext: true, monthNames: ['{$locMonthLong1}', '{$locMonthLong2}', '{$locMonthLong3}', '{$locMonthLong4}', '{$locMonthLong5}', '{$locMonthLong6}', '{$locMonthLong7}', '{$locMonthLong8}', '{$locMonthLong9}', '{$locMonthLong10}', '{$locMonthLong11}', '{$locMonthLong12}'], monthNamesShort: ['{$locMonthShort1}', '{$locMonthShort2}', '{$locMonthShort3}', '{$locMonthShort4}', '{$locMonthShort5}', '{$locMonthShort6}', '{$locMonthShort7}', '{$locMonthShort8}', '{$locMonthShort9}', '{$locMonthShort10}', '{$locMonthShort11}', '{$locMonthShort12}'], nextText: '{$lblNext}', prevText: '{$lblPrevious}', minDate: new Date(data[2].split('-')[0], parseInt(data[2].split('-')[1]) - 1, data[2].split('-')[2]), maxDate: new Date(data[3].split('-')[0], parseInt(data[3].split('-')[1]) - 1, data[3].split('-')[2]) }); }); } }, |
conf = $.extend({}, tool.conf, conf); | conf = $.extend(true, {}, tool.conf, conf); | $.fn.dateinput = function(conf) { // already instantiated if (this.data("dateinput")) { return this; } // configuration conf = $.extend({}, tool.conf, conf); // CSS prefix $.each(conf.css, function(key, val) { if (!val && key != 'prefix') { conf.css[key] = (conf.css.prefix || '') + (val || key); } }); var els; this.each(function() { var el = new Dateinput($(this), conf); instances.push(el); var input = el.getInput().data("dateinput", el); els = els ? els.add(input) : input; }); return els ? els : this; }; |
var tmp = $("<input/>").attr("name", input.attr("name")); | var tmp = $("<input/>"); $.each("name,readonly,disabled,value".split(","), function(i, attr) { tmp.attr(attr, input.attr(attr)); }); | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; // make sure min / max has values min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); // check that language exists if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } input.addClass(css.input); var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); // days of the week for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.d", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.d", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(css.week).each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.d"); $(document).unbind("keydown.d"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.bind("focus click", self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
.eq(1).attr("id", css.weeks).end().end() | .eq(1).attr("id", css.weeks).end().end().end() | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; // make sure min / max has values min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); // check that language exists if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } input.addClass(css.input); var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); // days of the week for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.d", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.d", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(css.week).each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.d"); $(document).unbind("keydown.d"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.bind("focus click", self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { | if ($(KEYS).index(key) >= 0) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; // make sure min / max has values min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); // check that language exists if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } input.addClass(css.input); var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); // days of the week for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.d", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.d", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(css.week).each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.d"); $(document).unbind("keydown.d"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.bind("focus click", self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
input.bind("focus click", self.show).keydown(function(e) { | input.bind("focus click", self.show).keypress(function(e) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; // make sure min / max has values min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); // check that language exists if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } input.addClass(css.input); var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); // days of the week for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.d", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.d", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(css.week).each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.d"); $(document).unbind("keydown.d"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.bind("focus click", self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { | if (root.is(":hidden") && $(KEYS).index(key) >= 0) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; // make sure min / max has values min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); // check that language exists if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } input.addClass(css.input); var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); // days of the week for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.d", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.d", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(css.week).each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.d"); $(document).unbind("keydown.d"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.bind("focus click", self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); | value = rfc3339(input.attr("data-value") || conf.value || input.val()) || new Date(), min = input.attr("min") || conf.min, max = input.attr("max") || conf.max; min = rfc3339(min) || roll(value, -Math.abs(min) || conf.yearRange[0] * 365); max = rfc3339(max) || roll(value, Math.abs(max) || conf.yearRange[1] * 365); if (!labels) { throw "Datepicker: invalid language: " + conf.lang; } | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); | var tmp = $("<input/>").attr("name", input.attr("name")); | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
root = $('<div><div><a/><div/><a/></div><div/><div/></div>') | root = $('<div><div><a/><div/><a/></div><div><div/><div/></div></div>') | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
.eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() | .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.body).children() .eq(0).attr("id", css.days).end() .eq(1).attr("id", css.weeks).end().end() | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
$.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); | for (var d = 0; d < 7; d++) { days.append($("<span>/").text(labels.shortDays[(d + conf.firstDay) % 7])); } | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
$(document).bind("keydown.dp", function(e) { | $(document).bind("keydown.d", function(e) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
$(window).bind("click.dp", function(e) { | $(window).bind("click.d", function(e) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { | if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
weeks.find(".week").each(function() { | weeks.find(css.week).each(function() { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
$(window).unbind("click.dp"); $(document).unbind("keydown.dp"); | $(window).unbind("click.d"); $(document).unbind("keydown.d"); | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
input.focus(self.show).keydown(function(e) { | input.bind("focus click", self.show).keydown(function(e) { | function Dateinput(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), trigger, pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || conf.value || input.val()), min = rfc3339(input.attr("min")) || rfc3339(conf.min) || roll(value, -Math.abs(conf.min) || conf.yearRange[0] * 365), max = rfc3339(input.attr("max")) || rfc3339(conf.max) || roll(value, conf.max || conf.yearRange[1] * 365); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser if (input.attr("type") == 'date') { var tmp = $("<input/>").addClass(css.input).attr("name", input.attr("name")); input.replaceWith(tmp); input = tmp; } var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>') .hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.prev).end().eq(1).attr("id", css.next); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.month), yearSelector = $("<select/>").attr("id", css.year); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // trigger icon if (conf.trigger) { trigger = $("<a/>").attr("href", "#").addClass(css.trigger).click(function(e) { self.show(); return e.preventDefault(); }).insertAfter(input); } // layout elements var weeks = root.find("#" + css.weeks); yearSelector = root.find("#" + css.year); monthSelector = root.find("#" + css.month); function pick(date, conf, e) { if (input.is("[readonly]")) { return; } // current value value = date; // onPick e.type = "change"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // store value into input input.data("date", date); // HTML5 DOM property input[0].valueAsDate = date; self.hide(e); } function onShow(ev) { ev.type = "onShow"; fire.trigger(ev); $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(e); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { if (root.is(":hidden")) { self.show(e); return e.preventDefault(); } var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return e.preventDefault(); } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.today(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } return $([16, 17, 18, 9]).index(key) >= 0; }); // click outside dateinput $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(e); } }); } $.extend(self, { show: function(e) { // onBeforeShow e = e || $.Event(); e.type = "onBeforeShow"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } $.each(instances, function() { this.hide(); }); // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.prev).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.next).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.today(); // show dateinputer var pos = input.offset(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, function() { onShow(e); }); } else { root.show(); onShow(e); } return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) { monthSelector.append($("<option/>").html(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var j = 0, a, num; j < 35; j++) { a = $("<a/>"); if (j % 7 === 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (j < begin) { a.addClass(css.off); num = prevDays - begin + j + 1; date = new Date(year, month-1, num); } else if (j >= begin + days) { a.addClass(css.off); num = j - days - begin + 1; date = new Date(year, month+1, num); } else { num = j - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, today: function() { return self.setDate(); }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, hide: function(e) { if (root.is(":visible")) { root.hide(); $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); // onHide e = e || $.Event(); e.type = "onHide"; fire.trigger(e); } return self; }, getConf: function() { return conf; }, getInput: function() { return input; }, getPicker: function() { return root; }, getDate: function(dateFormat) { return dateFormat ? format(value, dateFormat, conf.lang) : value; } }); // callbacks $.each("onBeforeShow,onShow,change,onHide".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API methods self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // show dateinput & assign keyboard shortcuts input.focus(self.show).keydown(function(e) { var key = e.keyCode; // open dateinput with navigation keyw if (root.is(":hidden") && $([75, 76, 38, 39, 74, 72, 40, 37]).index(key) >= 0) { self.show(e); return e.preventDefault(); } // allow tab return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault(); }); } |
input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); | function Datepicker(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || input.val()), min = rfc3339(input.attr("min")) || roll(value, conf.min), max = rfc3339(input.attr("max")) || roll(value, conf.max); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser var tmp = $('<input/>') .attr("type", "text") .attr("name", input.attr("name")) .addClass(input.attr("className")); input.replaceWith(tmp); input = tmp; var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>').hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.previousMonth).end().eq(1).attr("id", css.nextMonth); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.monthSelector), yearSelector = $("<select/>").attr("id", css.yearSelector); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // layout elements var weeks = root.find("#" + css.weeks), yearSelector = root.find("#" + css.yearSelector), monthSelector = root.find("#" + css.monthSelector); input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); function pick(date, conf, e) { // onBeforePick e.type = "onBeforePick"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // onPick e.type = "onPick"; fire.trigger(e, [date]); // store date input.data("date", date); self.hide(); } $.extend(self, { show: function() { // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.previousMonth).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.nextMonth).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.setDate(); // show datepickerer var pos = input.offset(), h = root.height(), w = root.width(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { // keyboard actions $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.setDate(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); // click outside datepicker $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if ((!min || min < new Date(year, i + 1, -1)) && (!max || max > new Date(year, i, 0))) { monthSelector.append($("<option/>").text(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if ((!min || min < new Date(i + 1, -1, 0)) && (!max || max > new Date(i, 0, 0))) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var i = 0, a, num; i < 35; i++) { a = $("<a/>"); if (i % 7 == 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (i < begin) { a.addClass(css.offmonth); num = prevDays - begin + i + 1; date = new Date(year, month-1, num); } else if (i >= begin + days) { a.addClass(css.offmonth); num = i - days - begin + 1; date = new Date(year, month+1, num); } else { num = i - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, bind: function(name, fn) { $(self).bind(name, fn); return self; }, unbind: function(name) { $(self).unbind(name); return self; }, hide: function() { $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); root.hide(); return self; }, getInput: function() { return input; } }); // callbacks $.each("onBeforePick,onPick".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { self.bind(name, conf[name]); } // API methods self[name] = function(fn) { return self.bind(name, fn); }; }); } |
|
function setupKeyboard() { $(document).bind("keydown.dp", function(e) { var key = e.keyCode; if (key == 27) { return self.hide(); } if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } if (key == 36) { return self.setDate(); } if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); $(window).bind("click.dp", function(e) { var el = e.target; if (!$(el).parents("#" + css.root).length && el != input[0] && el != trigger[0]) { self.hide(); } }); } | function Datepicker(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || input.val()), min = rfc3339(input.attr("min")) || roll(value, conf.min), max = rfc3339(input.attr("max")) || roll(value, conf.max); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser var tmp = $('<input/>') .attr("type", "text") .attr("name", input.attr("name")) .addClass(input.attr("className")); input.replaceWith(tmp); input = tmp; var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>').hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.previousMonth).end().eq(1).attr("id", css.nextMonth); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.monthSelector), yearSelector = $("<select/>").attr("id", css.yearSelector); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // layout elements var weeks = root.find("#" + css.weeks), yearSelector = root.find("#" + css.yearSelector), monthSelector = root.find("#" + css.monthSelector); input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); function pick(date, conf, e) { // onBeforePick e.type = "onBeforePick"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // onPick e.type = "onPick"; fire.trigger(e, [date]); // store date input.data("date", date); self.hide(); } $.extend(self, { show: function() { // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.previousMonth).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.nextMonth).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.setDate(); // show datepickerer var pos = input.offset(), h = root.height(), w = root.width(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { // keyboard actions $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.setDate(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); // click outside datepicker $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if ((!min || min < new Date(year, i + 1, -1)) && (!max || max > new Date(year, i, 0))) { monthSelector.append($("<option/>").text(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if ((!min || min < new Date(i + 1, -1, 0)) && (!max || max > new Date(i, 0, 0))) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var i = 0, a, num; i < 35; i++) { a = $("<a/>"); if (i % 7 == 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (i < begin) { a.addClass(css.offmonth); num = prevDays - begin + i + 1; date = new Date(year, month-1, num); } else if (i >= begin + days) { a.addClass(css.offmonth); num = i - days - begin + 1; date = new Date(year, month+1, num); } else { num = i - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, bind: function(name, fn) { $(self).bind(name, fn); return self; }, unbind: function(name) { $(self).unbind(name); return self; }, hide: function() { $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); root.hide(); return self; }, getInput: function() { return input; } }); // callbacks $.each("onBeforePick,onPick".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { self.bind(name, conf[name]); } // API methods self[name] = function(fn) { return self.bind(name, fn); }; }); } |
|
var pos = input.offset(), h = root.height(), w = root.width(); | var pos = input.offset(); | function Datepicker(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || input.val()), min = rfc3339(input.attr("min")) || roll(value, conf.min), max = rfc3339(input.attr("max")) || roll(value, conf.max); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser var tmp = $('<input/>') .attr("type", "text") .attr("name", input.attr("name")) .addClass(input.attr("className")); input.replaceWith(tmp); input = tmp; var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>').hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.previousMonth).end().eq(1).attr("id", css.nextMonth); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.monthSelector), yearSelector = $("<select/>").attr("id", css.yearSelector); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // layout elements var weeks = root.find("#" + css.weeks), yearSelector = root.find("#" + css.yearSelector), monthSelector = root.find("#" + css.monthSelector); input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); function pick(date, conf, e) { // onBeforePick e.type = "onBeforePick"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // onPick e.type = "onPick"; fire.trigger(e, [date]); // store date input.data("date", date); self.hide(); } $.extend(self, { show: function() { // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.previousMonth).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.nextMonth).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.setDate(); // show datepickerer var pos = input.offset(), h = root.height(), w = root.width(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { // keyboard actions $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.setDate(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); // click outside datepicker $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if ((!min || min < new Date(year, i + 1, -1)) && (!max || max > new Date(year, i, 0))) { monthSelector.append($("<option/>").text(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if ((!min || min < new Date(i + 1, -1, 0)) && (!max || max > new Date(i, 0, 0))) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var i = 0, a, num; i < 35; i++) { a = $("<a/>"); if (i % 7 == 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (i < begin) { a.addClass(css.offmonth); num = prevDays - begin + i + 1; date = new Date(year, month-1, num); } else if (i >= begin + days) { a.addClass(css.offmonth); num = i - days - begin + 1; date = new Date(year, month+1, num); } else { num = i - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, bind: function(name, fn) { $(self).bind(name, fn); return self; }, unbind: function(name) { $(self).unbind(name); return self; }, hide: function() { $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); root.hide(); return self; }, getInput: function() { return input; } }); // callbacks $.each("onBeforePick,onPick".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { self.bind(name, conf[name]); } // API methods self[name] = function(fn) { return self.bind(name, fn); }; }); } |
left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { $(document).bind("keydown.dp", function(e) { var key = e.keyCode; if (key == 27) { return self.hide(); } if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } if (key == 36) { return self.setDate(); } if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); | left: pos.left + conf.offset[1] }); if (conf.speed) { root.show(conf.speed, setupKeyboard); } else { root.show(); setupKeyboard(); } | function Datepicker(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || input.val()), min = rfc3339(input.attr("min")) || roll(value, conf.min), max = rfc3339(input.attr("max")) || roll(value, conf.max); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser var tmp = $('<input/>') .attr("type", "text") .attr("name", input.attr("name")) .addClass(input.attr("className")); input.replaceWith(tmp); input = tmp; var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>').hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.previousMonth).end().eq(1).attr("id", css.nextMonth); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.monthSelector), yearSelector = $("<select/>").attr("id", css.yearSelector); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // layout elements var weeks = root.find("#" + css.weeks), yearSelector = root.find("#" + css.yearSelector), monthSelector = root.find("#" + css.monthSelector); input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); function pick(date, conf, e) { // onBeforePick e.type = "onBeforePick"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // onPick e.type = "onPick"; fire.trigger(e, [date]); // store date input.data("date", date); self.hide(); } $.extend(self, { show: function() { // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.previousMonth).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.nextMonth).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.setDate(); // show datepickerer var pos = input.offset(), h = root.height(), w = root.width(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { // keyboard actions $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.setDate(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); // click outside datepicker $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if ((!min || min < new Date(year, i + 1, -1)) && (!max || max > new Date(year, i, 0))) { monthSelector.append($("<option/>").text(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if ((!min || min < new Date(i + 1, -1, 0)) && (!max || max > new Date(i, 0, 0))) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var i = 0, a, num; i < 35; i++) { a = $("<a/>"); if (i % 7 == 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (i < begin) { a.addClass(css.offmonth); num = prevDays - begin + i + 1; date = new Date(year, month-1, num); } else if (i >= begin + days) { a.addClass(css.offmonth); num = i - days - begin + 1; date = new Date(year, month+1, num); } else { num = i - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, bind: function(name, fn) { $(self).bind(name, fn); return self; }, unbind: function(name) { $(self).unbind(name); return self; }, hide: function() { $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); root.hide(); return self; }, getInput: function() { return input; } }); // callbacks $.each("onBeforePick,onPick".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { self.bind(name, conf[name]); } // API methods self[name] = function(fn) { return self.bind(name, fn); }; }); } |
input.focus(self.show).keydown(function(e) { var key = e.keyCode; return key == 9 || key == 27; }); trigger.click(self.show); | function Datepicker(input, conf) { // variables var self = this, css = conf.css, labels = LABELS[conf.lang], root = $("#" + css.root), title = root.find("#" + css.title), pm, nm, currYear, currMonth, currDay, value = rfc3339(input.attr("data-value") || input.val()), min = rfc3339(input.attr("min")) || roll(value, conf.min), max = rfc3339(input.attr("max")) || roll(value, conf.max); // Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser var tmp = $('<input/>') .attr("type", "text") .attr("name", input.attr("name")) .addClass(input.attr("className")); input.replaceWith(tmp); input = tmp; var fire = input.add(this); // default value if (value) { input.data("date", value); input.val(format(value, conf.format, conf.lang)); } // construct layout if (!root.length) { // root root = $('<div><div><a/><div/><a/></div><div/><div/></div>').hide().css({position: 'absolute'}).attr("id", css.root); // elements root.children() .eq(0).attr("id", css.head).end() .eq(1).attr("id", css.days).end() .eq(2).attr("id", css.weeks).end() .find("a").eq(0).attr("id", css.previousMonth).end().eq(1).attr("id", css.nextMonth); // title title = root.find("#" + css.head).find("div").attr("id", css.title); // year & month selectors if (conf.selectors) { var monthSelector = $("<select/>").attr("id", css.monthSelector), yearSelector = $("<select/>").attr("id", css.yearSelector); title.append(monthSelector.add(yearSelector)); } // day titles var days = root.find("#" + css.days); $.each(labels.shortDays, function(i, el) { days.append($("<span>/").text(el)); }); $("body").append(root); } // layout elements var weeks = root.find("#" + css.weeks), yearSelector = root.find("#" + css.yearSelector), monthSelector = root.find("#" + css.monthSelector); input.focus(function() { $.each(instances, function() { this.hide(); }); self.show(); }).keydown(function(e) { input.blur(); }); function pick(date, conf, e) { // onBeforePick e.type = "onBeforePick"; fire.trigger(e, [date]); if (e.isDefaultPrevented()) { return; } // formatting input.val(format(date, conf.format, conf.lang)); // onPick e.type = "onPick"; fire.trigger(e, [date]); // store date input.data("date", date); self.hide(); } $.extend(self, { show: function() { // month selector monthSelector.unbind("change").change(function() { self.setDate(yearSelector.val(), $(this).val()); }); // year selector yearSelector.unbind("change").change(function() { self.setDate($(this).val(), monthSelector.val()); }); // prev / next month pm = root.find("#" + css.previousMonth).unbind("click").click(function(e) { if (!pm.hasClass(css.disabled)) { self.prev(); } return false; }); nm = root.find("#" + css.nextMonth).unbind("click").click(function(e) { if (!nm.hasClass(css.disabled)) { self.next(); } return false; }); // set date self.setDate(); // show datepickerer var pos = input.offset(), h = root.height(), w = root.width(); root.css({ top: pos.top + input.outerHeight({margins: true}) + conf.offset[0], left: pos.left + conf.offset[1], width: 0, height: 0, opacity: 0 }).animate({height: h, width: w, opacity: 1}, conf.speed, conf.easing, function() { // keyboard actions $(document).bind("keydown.dp", function(e) { var key = e.keyCode; // esc key if (key == 27) { return self.hide(); } // h=72, j=74, k=75, l=76, down=40, left=37, up=38, right=39 if ($([75, 76, 38, 39, 74, 72, 40, 37]).index(key) != -1) { var days = $("#" + css.weeks + " a"), el = $("." + css.focus), index = days.index(el); el.removeClass(css.focus); if (key == 74 || key == 40) { index += 7; } else if (key == 75 || key == 38) { index -= 7; } else if (key == 76 || key == 39) { index += 1; } else if (key == 72 || key == 37) { index -= 1; } if (index == -1) { self.prev(); el = $("#" + css.weeks + " a:last"); } else if (index == 35) { self.next(); el = $("#" + css.weeks + " a:first"); } else { el = days.eq(index); } el.addClass(css.focus); return false; } // pageUp / pageDown if (key == 34) { return self.next(); } if (key == 33) { return self.prev(); } // home if (key == 36) { return self.setDate(); } // enter if (key == 13) { if (!$(e.target).is("select")) { pick($("." + css.focus).data("date"), conf, e); } } }); // click outside datepicker $(window).bind("click.dp", function(e) { var el = $(e.target); if (!el.parents("#" + css.root).length && el.index(input) !== 0) { self.hide(); } }); }); return self; }, setDate: function(year, month, day) { var date = new Date(year, month, day); // current year / month if (!year) { date = input.data("date") || new Date(); year = date.getYear() % 100 + 2000; month = date.getMonth(); day = date.getDate(); } // strings to numbers year = integer(year); month = integer(month); day = integer(day); // roll year & month if (month == -1) { month = 11; year--; } else if (month == 12) { month = 0; year++; } // variables var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(), days = dayAm(year, month), prevDays = dayAm(year, month - 1), week; // selectors if (conf.selectors) { // month selector monthSelector.empty(); $.each(labels.months, function(i, m) { if ((!min || min < new Date(year, i + 1, -1)) && (!max || max > new Date(year, i, 0))) { monthSelector.append($("<option/>").text(m).attr("value", i)); } }); // year selector yearSelector.empty(); for (var i = year + conf.yearRange[0]; i < year + conf.yearRange[1]; i++) { if ((!min || min < new Date(i + 1, -1, 0)) && (!max || max > new Date(i, 0, 0))) { yearSelector.append($("<option/>").text(i)); } } monthSelector.val(month); yearSelector.val(year); // title } else { title.html(labels.months[month] + " " + year); } // populate weeks weeks.empty(); pm.add(nm).removeClass(css.disabled); for (var i = 0, a, num; i < 35; i++) { a = $("<a/>"); if (i % 7 == 0) { week = $("<div/>").addClass(css.week); weeks.append(week); } if (i < begin) { a.addClass(css.offmonth); num = prevDays - begin + i + 1; date = new Date(year, month-1, num); } else if (i >= begin + days) { a.addClass(css.offmonth); num = i - days - begin + 1; date = new Date(year, month+1, num); } else { num = i - begin + 1; date = new Date(year, month, num); if (num === day) { a.attr("id", css.today).addClass(css.focus); } } // disabled if (min && date < min) { a.add(pm).addClass(css.disabled); } if (max && date > max) { a.add(nm).addClass(css.disabled); } a.attr("href", "#" + num).text(num).data("date", date); week.append(a); // date picking a.click(function(e) { if (!$(this).hasClass(css.disabled)) { pick($(this).data("date"), conf, e); } return false; }); } // sunday if (css.sunday) { weeks.find(".week").each(function() { var beg = conf.firstDay ? 7 - conf.firstDay : 0; $(this).children().slice(beg, beg + 1).addClass(css.sunday); }); } currMonth = month; currYear = year; currDay = day; return self; }, next: function(day) { return this.setDate(currYear, currMonth + 1, day); }, prev: function(day) { return this.setDate(currYear, currMonth - 1, day); }, nextYear: function(year, day) { return this.setDate(currYear + 1, currMonth, day); }, prevYear: function(year, day) { return this.setDate(currYear - 1, currMonth, day); }, bind: function(name, fn) { $(self).bind(name, fn); return self; }, unbind: function(name) { $(self).unbind(name); return self; }, hide: function() { $(window).unbind("click.dp"); $(document).unbind("keydown.dp"); root.hide(); return self; }, getInput: function() { return input; } }); // callbacks $.each("onBeforePick,onPick".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { self.bind(name, conf[name]); } // API methods self[name] = function(fn) { return self.bind(name, fn); }; }); } |
|
var a=e.getElement(i);a&&a.focus()}};this.delayHide=function(a){B=setTimeout(function(){B=null;if(f&&(a==null||i==a.id))d()},300)}}); | 0;n=a.id}a.className="sel";F(a)}};this.editKeyUp=function(a,b){if(i!=null)if(c(a))if(!((b.keyCode==13||b.keyCode==9)&&f.style.display=="none"))if(b.keyCode==27||b.keyCode==37||b.keyCode==39){f.style.display="none";if(b.keyCode==27){i=null;$(a).hasClass("Wt-suggest-dropdown")?d():a.blur()}}else if(a.value!=D)A.refilter();else(a=n?e.getElement(n):null)&&F(a)};f.lastChild.onclick=o;f.lastChild.onscroll=function(){if(B){clearTimeout(B);var a=e.getElement(i);a&&a.focus()}};this.delayHide=function(a){B= setTimeout(function(){B=null;if(f&&(a==null||i==a.id))d()},300)}}); | var a=e.getElement(i);a&&a.focus()}};this.delayHide=function(a){B=setTimeout(function(){B=null;if(f&&(a==null||i==a.id))d()},300)}}); |
var t = e.target || e.srcElement, p = t; | var t = WT.target(e), p = t; | function delegateCapture(e) { if (captureElement == null) return null; if (!e) e = window.event; if (e) { var t = e.target || e.srcElement, p = t; while (p && p != captureElement) p = p.parentNode; /* * We don't need to capture the event when the event falls inside the * capture element. In this way, more specific widgets inside may still * handle (and cancel) the event if they want. * * On IE this means that we need to delegate the event to the event * target; on other browsers we can just rely on event bubbling. */ if (p == captureElement) return WT.isIE ? t : null; else return captureElement; } else return captureElement;} |
}.bind(this) | }.bind(this), onFailure: indicateFail | deletePackage: function(event) { indicateLoad(); new Request({ method: 'get', url: '/json/remove_package/'+this.id, onSuccess: function(){ this.ele.nix(); indicateFinish(); }.bind(this) }).send(); event.stop(); }, |
$.post("/studydeck/decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); | $.post("/decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); | function deleteUserDeck(deckId, permanently){ if (permanently) { $.post("/studydeck/decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); } else { $.post("/studydeck/my_decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); } } |
$.post("/studydeck/my_decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); | $.post("/my_decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); | function deleteUserDeck(deckId, permanently){ if (permanently) { $.post("/studydeck/decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); } else { $.post("/studydeck/my_decks/delete",{id:deckId},function(){$("#userDeckRow"+ deckId).hide("fast");}); } } |
s(x);});},s=function(x){var y=x.config,z=y.plugins,A=y.extraPlugins,B=y.removePlugins;if(A){var C=new RegExp('(?:^|,)(?:'+A.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');z=z.replace(C,'');z+=','+A;}if(B){C=new RegExp('(?:^|,)(?:'+B.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');z=z.replace(C,'');}j.load(z.split(','),function(D){var E=[],F=[],G=[];x.plugins=D;for(var H in D){var I=D[H],J=I.lang,K=j.getPath(H),L=null;I.path=K;if(J){L=e.indexOf(J,x.langCode)>=0?x.langCode:J[0];if(!I.lang[L])G.push(a.getUrl(K+'lang/'+L+'.js'));else{e.extend(x.lang,I.lang[L]);L=null;}}F.push(L);E.push(I);}a.scriptLoader.load(G,function(){var M=['beforeInit','init','afterInit'];for(var N=0;N<M.length;N++)for(var O=0;O<E.length;O++){var P=E[O];if(N===0&&F[O]&&P.lang)e.extend(x.lang,P.lang[F[O]]);if(P[M[N]])P[M[N]](x);}x.fire('pluginsLoaded');u(x);});});},t=function(x){a.skins.load(x,'editor',function(){r(x);});},u=function(x){var y=x.config.theme;a.themes.load(y,function(){var z=x.theme=a.themes.get(y);z.path=a.themes.getPath(y);z.build(x);if(x.config.autoUpdateElement)v(x);});},v=function(x){var y=x.element;if(x.elementMode==1&&y.is('textarea')){var z=y.$.form&&new h(y.$.form);if(z){function A(){x.updateElement();};z.on('submit',A);if(!z.$.submit.nodeName)z.$.submit=e.override(z.$.submit,function(B){return function(){x.updateElement();if(B.apply)B.apply(this,arguments);else B();};});x.on('destroy',function(){z.removeListener('submit',A);});}}};function w(){var x,y=this._.commands,z=this.mode;for(var A in y){x=y[A];x[x.startDisabled?'disable':x.modes[z]?'enable':'disable']();}};a.editor.prototype._init=function(){var z=this;var x=h.get(z._.element),y=z._.instanceConfig;delete z._.element;delete z._.instanceConfig;z._.commands={};z._.styles=[];z.element=x;z.name=x&&z.elementMode==1&&(x.getId()||x.getNameAtt())||m();if(z.name in a.instances)throw '[CKEDITOR.editor] The instance "'+z.name+'" already exists.';z.config=e.prototypedCopy(i);z.ui=new k(z);z.focusManager=new a.focusManager(z);a.fire('instanceCreated',null,z);z.on('mode',w,null,null,1);p(z,y);};})();e.extend(a.editor.prototype,{addCommand:function(l,m){return this._.commands[l]=new a.command(this,m);},addCss:function(l){this._.styles.push(l);},destroy:function(l){var r=this;if(!l)r.updateElement();if(r.mode)r._.modes[r.mode].unload(r.getThemeSpace('contents'));r.theme.destroy(r);var m,n=0,o,p,q;if(r.toolbox){m=r.toolbox.toolbars;for(;n<m.length;n++){p=m[n].items;for(o=0;o<p.length;o++){q=p[o];if(q.clickFn)e.removeFunction(q.clickFn);if(q.keyDownFn)e.removeFunction(q.keyDownFn); if(q.index)k.button._.instances[q.index]=null;}}}if(r.contextMenu)e.removeFunction(r.contextMenu._.functionId);if(r._.filebrowserFn)e.removeFunction(r._.filebrowserFn);r.fire('destroy');a.remove(r);a.fire('instanceDestroyed',null,r);},execCommand:function(l,m){var n=this.getCommand(l),o={name:l,commandData:m,command:n};if(n&&n.state!=0)if(this.fire('beforeCommandExec',o)!==true){o.returnValue=n.exec(o.commandData);if(!n.async&&this.fire('afterCommandExec',o)!==true)return o.returnValue;}return false;},getCommand:function(l){return this._.commands[l];},getData:function(){var n=this;n.fire('beforeGetData');var l=n._.data;if(typeof l!='string'){var m=n.element;if(m&&n.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();else l='';}l={dataValue:l};n.fire('getData',l);return l.dataValue;},getSnapshot:function(){var l=this.fire('getSnapshot');if(typeof l!='string'){var m=this.element;if(m&&this.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();}return l;},loadSnapshot:function(l){this.fire('loadSnapshot',l);},setData:function(l,m){if(m)this.on('dataReady',function(o){o.removeListener();m.call(o.editor);});var n={dataValue:l};this.fire('setData',n);this._.data=n.dataValue;this.fire('afterSetData',n);},insertHtml:function(l){this.fire('insertHtml',l);},insertElement:function(l){this.fire('insertElement',l);},checkDirty:function(){return this.mayBeDirty&&this._.previousValue!==this.getSnapshot();},resetDirty:function(){if(this.mayBeDirty)this._.previousValue=this.getSnapshot();},updateElement:function(){var n=this;var l=n.element;if(l&&n.elementMode==1){var m=n.getData();if(n.config.htmlEncodeOutput)m=e.htmlEncode(m);if(l.is('textarea'))l.setValue(m);else l.setHtml(m);}}});a.on('loaded',function(){var l=a.editor._pending;if(l){delete a.editor._pending;for(var m=0;m<l.length;m++)l[m]._init();}});a.htmlParser=function(){this._={htmlPartsRegex:new RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s); | x.plugins=D;for(var H in D){var I=D[H],J=I.lang,K=j.getPath(H),L=null;I.path=K;if(J){L=e.indexOf(J,x.langCode)>=0?x.langCode:J[0];if(!I.lang[L])G.push(a.getUrl(K+'lang/'+L+'.js'));else{e.extend(x.lang,I.lang[L]);L=null;}}F.push(L);E.push(I);}a.scriptLoader.load(G,function(){var M=['beforeInit','init','afterInit'];for(var N=0;N<M.length;N++)for(var O=0;O<E.length;O++){var P=E[O];if(N===0&&F[O]&&P.lang)e.extend(x.lang,P.lang[F[O]]);if(P[M[N]])P[M[N]](x);}x.fire('pluginsLoaded');u(x);});});},t=function(x){a.skins.load(x,'editor',function(){r(x);});},u=function(x){var y=x.config.theme;a.themes.load(y,function(){var z=x.theme=a.themes.get(y);z.path=a.themes.getPath(y);z.build(x);if(x.config.autoUpdateElement)v(x);});},v=function(x){var y=x.element;if(x.elementMode==1&&y.is('textarea')){var z=y.$.form&&new h(y.$.form);if(z){function A(){x.updateElement();};z.on('submit',A);if(!z.$.submit.nodeName)z.$.submit=e.override(z.$.submit,function(B){return function(){x.updateElement();if(B.apply)B.apply(this,arguments);else B();};});x.on('destroy',function(){z.removeListener('submit',A);});}}};function w(){var x,y=this._.commands,z=this.mode;for(var A in y){x=y[A];x[x.startDisabled?'disable':x.modes[z]?'enable':'disable']();}};a.editor.prototype._init=function(){var z=this;var x=h.get(z._.element),y=z._.instanceConfig;delete z._.element;delete z._.instanceConfig;z._.commands={};z._.styles=[];z.element=x;z.name=x&&z.elementMode==1&&(x.getId()||x.getNameAtt())||m();if(z.name in a.instances)throw '[CKEDITOR.editor] The instance "'+z.name+'" already exists.';z.config=e.prototypedCopy(i);z.ui=new k(z);z.focusManager=new a.focusManager(z);a.fire('instanceCreated',null,z);z.on('mode',w,null,null,1);p(z,y);};})();e.extend(a.editor.prototype,{addCommand:function(l,m){return this._.commands[l]=new a.command(this,m);},addCss:function(l){this._.styles.push(l);},destroy:function(l){var r=this;if(!l)r.updateElement();if(r.mode)r._.modes[r.mode].unload(r.getThemeSpace('contents'));r.theme.destroy(r);var m,n=0,o,p,q;if(r.toolbox){m=r.toolbox.toolbars;for(;n<m.length;n++){p=m[n].items;for(o=0;o<p.length;o++){q=p[o];if(q.clickFn)e.removeFunction(q.clickFn);if(q.keyDownFn)e.removeFunction(q.keyDownFn);if(q.index)k.button._.instances[q.index]=null;}}}if(r.contextMenu)e.removeFunction(r.contextMenu._.functionId);if(r._.filebrowserFn)e.removeFunction(r._.filebrowserFn);r.fire('destroy');a.remove(r);a.fire('instanceDestroyed',null,r);},execCommand:function(l,m){var n=this.getCommand(l),o={name:l,commandData:m,command:n}; | s(x);});},s=function(x){var y=x.config,z=y.plugins,A=y.extraPlugins,B=y.removePlugins;if(A){var C=new RegExp('(?:^|,)(?:'+A.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');z=z.replace(C,'');z+=','+A;}if(B){C=new RegExp('(?:^|,)(?:'+B.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');z=z.replace(C,'');}j.load(z.split(','),function(D){var E=[],F=[],G=[];x.plugins=D;for(var H in D){var I=D[H],J=I.lang,K=j.getPath(H),L=null;I.path=K;if(J){L=e.indexOf(J,x.langCode)>=0?x.langCode:J[0];if(!I.lang[L])G.push(a.getUrl(K+'lang/'+L+'.js'));else{e.extend(x.lang,I.lang[L]);L=null;}}F.push(L);E.push(I);}a.scriptLoader.load(G,function(){var M=['beforeInit','init','afterInit'];for(var N=0;N<M.length;N++)for(var O=0;O<E.length;O++){var P=E[O];if(N===0&&F[O]&&P.lang)e.extend(x.lang,P.lang[F[O]]);if(P[M[N]])P[M[N]](x);}x.fire('pluginsLoaded');u(x);});});},t=function(x){a.skins.load(x,'editor',function(){r(x);});},u=function(x){var y=x.config.theme;a.themes.load(y,function(){var z=x.theme=a.themes.get(y);z.path=a.themes.getPath(y);z.build(x);if(x.config.autoUpdateElement)v(x);});},v=function(x){var y=x.element;if(x.elementMode==1&&y.is('textarea')){var z=y.$.form&&new h(y.$.form);if(z){function A(){x.updateElement();};z.on('submit',A);if(!z.$.submit.nodeName)z.$.submit=e.override(z.$.submit,function(B){return function(){x.updateElement();if(B.apply)B.apply(this,arguments);else B();};});x.on('destroy',function(){z.removeListener('submit',A);});}}};function w(){var x,y=this._.commands,z=this.mode;for(var A in y){x=y[A];x[x.startDisabled?'disable':x.modes[z]?'enable':'disable']();}};a.editor.prototype._init=function(){var z=this;var x=h.get(z._.element),y=z._.instanceConfig;delete z._.element;delete z._.instanceConfig;z._.commands={};z._.styles=[];z.element=x;z.name=x&&z.elementMode==1&&(x.getId()||x.getNameAtt())||m();if(z.name in a.instances)throw '[CKEDITOR.editor] The instance "'+z.name+'" already exists.';z.config=e.prototypedCopy(i);z.ui=new k(z);z.focusManager=new a.focusManager(z);a.fire('instanceCreated',null,z);z.on('mode',w,null,null,1);p(z,y);};})();e.extend(a.editor.prototype,{addCommand:function(l,m){return this._.commands[l]=new a.command(this,m);},addCss:function(l){this._.styles.push(l);},destroy:function(l){var r=this;if(!l)r.updateElement();if(r.mode)r._.modes[r.mode].unload(r.getThemeSpace('contents'));r.theme.destroy(r);var m,n=0,o,p,q;if(r.toolbox){m=r.toolbox.toolbars;for(;n<m.length;n++){p=m[n].items;for(o=0;o<p.length;o++){q=p[o];if(q.clickFn)e.removeFunction(q.clickFn);if(q.keyDownFn)e.removeFunction(q.keyDownFn);if(q.index)k.button._.instances[q.index]=null;}}}if(r.contextMenu)e.removeFunction(r.contextMenu._.functionId);if(r._.filebrowserFn)e.removeFunction(r._.filebrowserFn);r.fire('destroy');a.remove(r);a.fire('instanceDestroyed',null,r);},execCommand:function(l,m){var n=this.getCommand(l),o={name:l,commandData:m,command:n};if(n&&n.state!=0)if(this.fire('beforeCommandExec',o)!==true){o.returnValue=n.exec(o.commandData);if(!n.async&&this.fire('afterCommandExec',o)!==true)return o.returnValue;}return false;},getCommand:function(l){return this._.commands[l];},getData:function(){var n=this;n.fire('beforeGetData');var l=n._.data;if(typeof l!='string'){var m=n.element;if(m&&n.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();else l='';}l={dataValue:l};n.fire('getData',l);return l.dataValue;},getSnapshot:function(){var l=this.fire('getSnapshot');if(typeof l!='string'){var m=this.element;if(m&&this.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();}return l;},loadSnapshot:function(l){this.fire('loadSnapshot',l);},setData:function(l,m){if(m)this.on('dataReady',function(o){o.removeListener();m.call(o.editor);});var n={dataValue:l};this.fire('setData',n);this._.data=n.dataValue;this.fire('afterSetData',n);},insertHtml:function(l){this.fire('insertHtml',l);},insertElement:function(l){this.fire('insertElement',l);},checkDirty:function(){return this.mayBeDirty&&this._.previousValue!==this.getSnapshot();},resetDirty:function(){if(this.mayBeDirty)this._.previousValue=this.getSnapshot();},updateElement:function(){var n=this;var l=n.element;if(l&&n.elementMode==1){var m=n.getData();if(n.config.htmlEncodeOutput)m=e.htmlEncode(m);if(l.is('textarea'))l.setValue(m);else l.setHtml(m);}}});a.on('loaded',function(){var l=a.editor._pending;if(l){delete a.editor._pending;for(var m=0;m<l.length;m++)l[m]._init();}});a.htmlParser=function(){this._={htmlPartsRegex:new RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s); |
editing = false; | function destroyElement() { // get parent var parent = options.current.element.parent(); // set HTML and rebind events parent.html(options.current.element.val()) .bind('click focus', createElement); // add class parent.removeClass('inlineEditing'); } |
|
this.each(function(h){var k=d(this),l=k.html();k.empty().append(function(){return a.call(this,h,l)})}):this.empty().append(a);return this},replaceWith:function(a){return this[0]&&this[0].parentNode?this.each(function(){var b=this.nextSibling,e=this.parentNode;d(this).remove();b?d(b).before(a):d(e).append(a)}):this.pushStack(d(d.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,e){function g(w){return d.nodeName(w,"table")?w.getElementsByTagName("tbody")[0]|| | 1){M(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}else c.isFunction(a)?this.each(function(h){var k=c(this),l=k.html();k.empty().append(function(){return a.call(this,h,l)})}):this.empty().append(a);return this},replaceWith:function(a){return this[0]&&this[0].parentNode?this.each(function(){var b=this.nextSibling,e=this.parentNode;c(this).remove();b?c(b).before(a):c(e).append(a)}):this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a, true)},domManip:function(a,b,e){function f(w){return c.nodeName(w,"table")?w.getElementsByTagName("tbody")[0]||w.appendChild(w.ownerDocument.createElement("tbody")):w}var h,k,l=a[0],q=[];if(c.isFunction(l))return this.each(function(w){var A=c(this);a[0]=l.call(this,w,b?A.html():v);return A.domManip(a,b,e)});if(this[0]){h=a[0]&&a[0].parentNode&&a[0].parentNode.nodeType===11?{fragment:a[0].parentNode}:aa(a,this,q);if(k=h.fragment.firstChild){b=b&&c.nodeName(k,"tr");for(var p=0,o=this.length;p<o;p++)e.call(b? | this.each(function(h){var k=d(this),l=k.html();k.empty().append(function(){return a.call(this,h,l)})}):this.empty().append(a);return this},replaceWith:function(a){return this[0]&&this[0].parentNode?this.each(function(){var b=this.nextSibling,e=this.parentNode;d(this).remove();b?d(b).before(a):d(e).append(a)}):this.pushStack(d(d.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,e){function g(w){return d.nodeName(w,"table")?w.getElementsByTagName("tbody")[0]|| |
if (container === undefined || container == null) return; | detachMRUpopup: function () { alert("detach"); var container = this._currentWindow.document.getElementById("KeeFox_ChangeDB-Button"); //var popupContainer = this._currentWindow.document.getElementById("KeeFox_ChangeDB-Popup"); // Remove all of the existing popup containers for (i = container.childNodes.length; i > 0; i--) { container.removeChild(container.childNodes[0]); } }, |
|
var i=a.config;a.focusManager=function(j){if(j.focusManager)return j.focusManager;this.hasFocus=false;this._={editor:j};return this;};a.focusManager.prototype={focus:function(){var k=this;if(k._.timer)clearTimeout(k._.timer);if(!k.hasFocus){if(a.currentInstance)a.currentInstance.focusManager.forceBlur();var j=k._.editor;j.container.getChild(1).addClass('cke_focus');k.hasFocus=true;j.fire('focus');}},blur:function(){var j=this;if(j._.timer)clearTimeout(j._.timer);j._.timer=setTimeout(function(){delete j._.timer;j.forceBlur();},100);},forceBlur:function(){if(this.hasFocus){var j=this._.editor;j.container.getChild(1).removeClass('cke_focus');this.hasFocus=false;j.fire('blur');}}};(function(){var j={};a.lang={languages:{af:1,ar:1,bg:1,bn:1,bs:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,'en-au':1,'en-ca':1,'en-gb':1,en:1,eo:1,es:1,et:1,eu:1,fa:1,fi:1,fo:1,'fr-ca':1,fr:1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,is:1,it:1,ja:1,km:1,ko:1,lt:1,lv:1,mn:1,ms:1,nb:1,nl:1,no:1,pl:1,'pt-br':1,pt:1,ro:1,ru:1,sk:1,sl:1,'sr-latn':1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,'zh-cn':1,zh:1},load:function(k,l,m){if(!k||!a.lang.languages[k])k=this.detect(l,k);if(!this[k])a.scriptLoader.load(a.getUrl('lang/'+k+'.js'),function(){m(k,this[k]);},this);else m(k,this[k]);},detect:function(k,l){var m=this.languages;l=l||navigator.userLanguage||navigator.language;var n=l.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),o=n[1],p=n[2];if(m[o+'-'+p])o=o+'-'+p;else if(!m[o])o=null;a.lang.detect=o?function(){return o;}:function(q){return q;};return o||k;}};})();a.scriptLoader=(function(){var j={},k={};return{load:function(l,m,n,o,p){var q=typeof l=='string';if(q)l=[l];if(!n)n=a;var r=l.length,s=[],t=[],u=function(z){if(m)if(q)m.call(n,z);else m.call(n,s,t);};if(r===0){u(true);return;}var v=function(z,A){(A?s:t).push(z);if(--r<=0){p&&a.document.getDocumentElement().removeStyle('cursor');u(A);}},w=function(z,A){j[z]=1;var B=k[z];delete k[z];for(var C=0;C<B.length;C++)B[C](z,A);},x=function(z){if(o!==true&&j[z]){v(z,true);return;}var A=k[z]||(k[z]=[]);A.push(v);if(A.length>1)return;var B=new h('script');B.setAttributes({type:'text/javascript',src:z});if(m)if(c)B.$.onreadystatechange=function(){if(B.$.readyState=='loaded'||B.$.readyState=='complete'){B.$.onreadystatechange=null;w(z,true);}};else{B.$.onload=function(){setTimeout(function(){w(z,true);},0);};B.$.onerror=function(){w(z,false);};}B.appendTo(a.document.getHead());};p&&a.document.getDocumentElement().setStyle('cursor','wait');for(var y=0;y<r;y++)x(l[y]);},loadCode:function(l){var m=new h('script'); | j.forceBlur();},100);},forceBlur:function(){if(this.hasFocus){var j=this._.editor;j.container.getChild(1).removeClass('cke_focus');this.hasFocus=false;j.fire('blur');}}};(function(){var j={};a.lang={languages:{af:1,ar:1,bg:1,bn:1,bs:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,'en-au':1,'en-ca':1,'en-gb':1,en:1,eo:1,es:1,et:1,eu:1,fa:1,fi:1,fo:1,'fr-ca':1,fr:1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,is:1,it:1,ja:1,km:1,ko:1,lt:1,lv:1,mn:1,ms:1,nb:1,nl:1,no:1,pl:1,'pt-br':1,pt:1,ro:1,ru:1,sk:1,sl:1,'sr-latn':1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,'zh-cn':1,zh:1},load:function(k,l,m){if(!k||!a.lang.languages[k])k=this.detect(l,k);if(!this[k])a.scriptLoader.load(a.getUrl('lang/'+k+'.js'),function(){m(k,this[k]);},this);else m(k,this[k]);},detect:function(k,l){var m=this.languages;l=l||navigator.userLanguage||navigator.language;var n=l.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),o=n[1],p=n[2];if(m[o+'-'+p])o=o+'-'+p;else if(!m[o])o=null;a.lang.detect=o?function(){return o;}:function(q){return q;};return o||k;}};})();a.scriptLoader=(function(){var j={},k={};return{load:function(l,m,n,o,p){var q=typeof l=='string';if(q)l=[l];if(!n)n=a;var r=l.length,s=[],t=[],u=function(z){if(m)if(q)m.call(n,z);else m.call(n,s,t);};if(r===0){u(true);return;}var v=function(z,A){(A?s:t).push(z);if(--r<=0){p&&a.document.getDocumentElement().removeStyle('cursor');u(A);}},w=function(z,A){j[z]=1;var B=k[z];delete k[z];for(var C=0;C<B.length;C++)B[C](z,A);},x=function(z){if(o!==true&&j[z]){v(z,true);return;}var A=k[z]||(k[z]=[]);A.push(v);if(A.length>1)return;var B=new h('script');B.setAttributes({type:'text/javascript',src:z});if(m)if(c)B.$.onreadystatechange=function(){if(B.$.readyState=='loaded'||B.$.readyState=='complete'){B.$.onreadystatechange=null;w(z,true);}};else{B.$.onload=function(){setTimeout(function(){w(z,true);},0);};B.$.onerror=function(){w(z,false);};}B.appendTo(a.document.getHead());};p&&a.document.getDocumentElement().setStyle('cursor','wait');for(var y=0;y<r;y++)x(l[y]);},loadCode:function(l){var m=new h('script');m.setAttribute('type','text/javascript');m.appendText(l);m.appendTo(a.document.getHead());}};})();a.resourceManager=function(j,k){var l=this;l.basePath=j;l.fileName=k;l.registered={};l.loaded={};l.externals={};l._={waitingList:{}};};a.resourceManager.prototype={add:function(j,k){if(this.registered[j])throw '[CKEDITOR.resourceManager.add] The resource name "'+j+'" is already registered.';a.fire(j+e.capitalize(this.fileName)+'Ready',this.registered[j]=k||{});},get:function(j){return this.registered[j]||null; | var i=a.config;a.focusManager=function(j){if(j.focusManager)return j.focusManager;this.hasFocus=false;this._={editor:j};return this;};a.focusManager.prototype={focus:function(){var k=this;if(k._.timer)clearTimeout(k._.timer);if(!k.hasFocus){if(a.currentInstance)a.currentInstance.focusManager.forceBlur();var j=k._.editor;j.container.getChild(1).addClass('cke_focus');k.hasFocus=true;j.fire('focus');}},blur:function(){var j=this;if(j._.timer)clearTimeout(j._.timer);j._.timer=setTimeout(function(){delete j._.timer;j.forceBlur();},100);},forceBlur:function(){if(this.hasFocus){var j=this._.editor;j.container.getChild(1).removeClass('cke_focus');this.hasFocus=false;j.fire('blur');}}};(function(){var j={};a.lang={languages:{af:1,ar:1,bg:1,bn:1,bs:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,'en-au':1,'en-ca':1,'en-gb':1,en:1,eo:1,es:1,et:1,eu:1,fa:1,fi:1,fo:1,'fr-ca':1,fr:1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,is:1,it:1,ja:1,km:1,ko:1,lt:1,lv:1,mn:1,ms:1,nb:1,nl:1,no:1,pl:1,'pt-br':1,pt:1,ro:1,ru:1,sk:1,sl:1,'sr-latn':1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,'zh-cn':1,zh:1},load:function(k,l,m){if(!k||!a.lang.languages[k])k=this.detect(l,k);if(!this[k])a.scriptLoader.load(a.getUrl('lang/'+k+'.js'),function(){m(k,this[k]);},this);else m(k,this[k]);},detect:function(k,l){var m=this.languages;l=l||navigator.userLanguage||navigator.language;var n=l.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),o=n[1],p=n[2];if(m[o+'-'+p])o=o+'-'+p;else if(!m[o])o=null;a.lang.detect=o?function(){return o;}:function(q){return q;};return o||k;}};})();a.scriptLoader=(function(){var j={},k={};return{load:function(l,m,n,o,p){var q=typeof l=='string';if(q)l=[l];if(!n)n=a;var r=l.length,s=[],t=[],u=function(z){if(m)if(q)m.call(n,z);else m.call(n,s,t);};if(r===0){u(true);return;}var v=function(z,A){(A?s:t).push(z);if(--r<=0){p&&a.document.getDocumentElement().removeStyle('cursor');u(A);}},w=function(z,A){j[z]=1;var B=k[z];delete k[z];for(var C=0;C<B.length;C++)B[C](z,A);},x=function(z){if(o!==true&&j[z]){v(z,true);return;}var A=k[z]||(k[z]=[]);A.push(v);if(A.length>1)return;var B=new h('script');B.setAttributes({type:'text/javascript',src:z});if(m)if(c)B.$.onreadystatechange=function(){if(B.$.readyState=='loaded'||B.$.readyState=='complete'){B.$.onreadystatechange=null;w(z,true);}};else{B.$.onload=function(){setTimeout(function(){w(z,true);},0);};B.$.onerror=function(){w(z,false);};}B.appendTo(a.document.getHead());};p&&a.document.getDocumentElement().setStyle('cursor','wait');for(var y=0;y<r;y++)x(l[y]);},loadCode:function(l){var m=new h('script'); |
if (!name) { return false; } | function detectImport() { var name = Zotero.getXML().name(); return name.uri == "http://www.loc.gov/mods/v3" && (name.localName == "modsCollection" || name.localName == "mods");} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.