Cmscout1.00rc2 > Includes / Formtool.js

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Cmscout1.00rc2

Download:
cmscout1.00rc2.zip

Category:
Content Management

Archive Content:

Content:

Admin

Content:

Avatars

Cache

Calendar

Calendar > Lang

Content:

Docs

Content:

Downloads

Content:

Forums

Content:

Images

Includes

Includes > Internals

Includes > Plugins

Includes

Content:

Install

Install > Templates C

Install

Content:

Photos

Pm

Content:

Sidebox

Content:

Templates > Admin

Templates > Admin > Images

Templates > Admin

Templates > CMScout

Templates > CMScout > Images

Templates > CMScout

Templates

Templates C

Content:

Tiny Mce

Tiny Mce > Langs

Tiny Mce > Plugins > Advhr

Tiny Mce > Plugins > Advhr > Images

Tiny Mce > Plugins > Advhr > Jscripts

Tiny Mce > Plugins > Advhr > Langs

Tiny Mce > Plugins > Advhr

Tiny Mce > Plugins > Advimage > Css

Tiny Mce > Plugins > Advimage

Tiny Mce > Plugins > Advimage > Images

Tiny Mce > Plugins > Advimage > Jscripts

Tiny Mce > Plugins > Advimage > Langs

Tiny Mce > Plugins > Advlink > Css

Tiny Mce > Plugins > Advlink

Tiny Mce > Plugins > Advlink > Jscripts

Tiny Mce > Plugins > Advlink > Langs

Tiny Mce > Plugins > Advlink

Tiny Mce > Plugins > Autosave

Tiny Mce > Plugins > Autosave > Langs

Tiny Mce > Plugins > Contextmenu > Css

Tiny Mce > Plugins > Contextmenu

Tiny Mce > Plugins > Contextmenu > Images

Tiny Mce > Plugins > Directionality

Tiny Mce > Plugins > Directionality > Images

Tiny Mce > Plugins > Directionality > Langs

Tiny Mce > Plugins > Emotions

Tiny Mce > Plugins > Emotions > Images

Tiny Mce > Plugins > Emotions > Jscripts

Tiny Mce > Plugins > Emotions > Langs

Tiny Mce > Plugins > Fullscreen

Tiny Mce > Plugins > Fullscreen > Images

Tiny Mce > Plugins > Fullscreen > Langs

Tiny Mce > Plugins > Ibrowser > Config

Tiny Mce > Plugins > Ibrowser > Css

Tiny Mce > Plugins > Ibrowser

Tiny Mce > Plugins > Ibrowser > Images

Tiny Mce > Plugins > Ibrowser

Tiny Mce > Plugins > Ibrowser > Interface

Tiny Mce > Plugins > Ibrowser > Interface > Images > TinyMCE

Tiny Mce > Plugins > Ibrowser > Interface

Tiny Mce > Plugins > Ibrowser > Langs

Tiny Mce > Plugins > Ibrowser > Scripts

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Cache

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Cache > Source

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Demo

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Docs

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Fonts

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb

Tiny Mce > Plugins > Ibrowser > Scripts

Tiny Mce > Plugins > Ibrowser > Temp

Tiny Mce > Plugins

Tiny Mce > Plugins > Inlinepopups > Css

Tiny Mce > Plugins > Inlinepopups

Tiny Mce > Plugins > Inlinepopups > Images

Tiny Mce > Plugins > Inlinepopups > Jscripts

Tiny Mce > Plugins > Insertdatetime

Tiny Mce > Plugins > Insertdatetime > Images

Tiny Mce > Plugins > Insertdatetime > Langs

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Paste > Css

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Paste > Images

Tiny Mce > Plugins > Paste > Jscripts

Tiny Mce > Plugins > Paste > Langs

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Preview

Tiny Mce > Plugins > Preview > Images

Tiny Mce > Plugins > Preview > Langs

Tiny Mce > Plugins > Print

Tiny Mce > Plugins > Print > Images

Tiny Mce > Plugins > Print > Langs

Tiny Mce > Plugins > Searchreplace

Tiny Mce > Plugins > Searchreplace > Images

Tiny Mce > Plugins > Searchreplace > Jscripts

Tiny Mce > Plugins > Searchreplace > Langs

Tiny Mce > Plugins > Searchreplace

Tiny Mce > Plugins > Table

Tiny Mce > Plugins > Table > Css

Tiny Mce > Plugins > Table

Tiny Mce > Plugins > Table > Images

Tiny Mce > Plugins > Table > Jscripts

Tiny Mce > Plugins > Table > Langs

Tiny Mce > Plugins > Table

Tiny Mce > Themes > Advanced

Tiny Mce > Themes > Advanced > Css

Tiny Mce > Themes > Advanced > Docs > En

Tiny Mce > Themes > Advanced > Docs > En > Images

Tiny Mce > Themes > Advanced > Docs > En

Tiny Mce > Themes > Advanced > Docs > Images

Tiny Mce > Themes > Advanced

Tiny Mce > Themes > Advanced > Images

Tiny Mce > Themes > Advanced > Images > Xp

Tiny Mce > Themes > Advanced > Jscripts

Tiny Mce > Themes > Advanced > Langs

Tiny Mce > Themes > Advanced

Tiny Mce

Tiny Mce > Utils

Content:

Formtool.js:


//------------------------------------------------------------------------------
//  SmartyFormtool Javascript Library version 1.3
//  http://www.phpinsider.com/php/code/SmartyFormtool/
//
//  Copyright(c) 2004 ispi. All rights reserved.
//
//  This library is free software; you can redistribute it and/or modify it
//  under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation; either version 2.1 of the License,  or (at
//  your option) any later version.
//
//  This library is distributed in the hope that it will be useful,  but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
//  License for more details.
//------------------------------------------------------------------------------

ischecked = new Object();
function formtool_checkall(id,  field,  check_text,  uncheck_text) {
   if (ischecked[id] != "true") {
     for (i = 0; i < field.length; i++) { field[i].checked = true; }
     ischecked[id] = "true";
     return uncheck_text;
    } else {
     for (i = 0; i < field.length; i++) { field[i].checked = false; }
     ischecked[id] = "false";
     return check_text;
   }
}

var isselected = new Object();
function formtool_selectall(id,  field,  select_text,  unselect_text) {
   if (isselected[id] != "true") {
     for (i = 0; i < field.length; i++) { field.options[i].selected = true; }
     isselected[id] = "true";
     return unselect_text;
   } else {
     for (i = 0; i < field.length; i++) { field.options[i].selected = false; }
     isselected[id] = "false";
     return select_text;
   }
}

function formtool_moveup(field, save) {
    for (i = 0; i < field.length; i++) {
        if(field.options[i].selected == true && i > 0) {
            var tmplabel = field.options[i-1].label;
            var tmpval = field.options[i-1].value;
            var tmptext = field.options[i-1].text;
            var tmpsel = field.options[i-1].selected;
            field.options[i-1].label = field.options[i].label;
            field.options[i-1].value = field.options[i].value;
            field.options[i-1].text = field.options[i].text;
            field.options[i-1].selected = field.options[i].selected;
            field.options[i].label = tmplabel;
            field.options[i].value = tmpval;
            field.options[i].text = tmptext;
            field.options[i].selected = tmpsel;
        }
    }
    formtool_save(field, save);
}

function formtool_movedown(field, save) {
    var max = field.length - 1;
    for (i = max; i >= 0; i--) {
        if(field.options[i].selected == true && i < max) {
            var tmplabel = field.options[i+1].label;
            var tmpval = field.options[i+1].value;
            var tmptext = field.options[i+1].text;
            var tmpsel = field.options[i+1].selected;
            field.options[i+1].label = field.options[i].label;
            field.options[i+1].value = field.options[i].value;
            field.options[i+1].text = field.options[i].text;
            field.options[i+1].selected = field.options[i].selected;
            field.options[i].label = tmplabel;
            field.options[i].value = tmpval;
            field.options[i].text = tmptext;
            field.options[i].selected = tmpsel;
        }
    }
    formtool_save(field, save);
}

function formtool_save(choices, storage) {
    order = new Array();
    for(i=0; i<choices.length; i++) {
        order[i] = choices.options[i].value;
    }
    storage.value = order.join(", ");
}


function formtool_rename(field, text, save) {
    for (i = 0; i < field.length; i++) {
        if(field.options[i].selected == true) {
            field.options[i].text = text;
            field.options[i].value = text;
        }
    }
    formtool_save(field, save);
    return '';
}

function formtool_move(field1, field2, save_from, save_to, counter_from, counter_to, moveall) {
    if (moveall == true) {
        formtool_add_all(field1, field2, false);
        formtool_remove_all(field1, field2);
    } else {
        formtool_add_item(field1, field2, false);
        formtool_remove_item(field1);
    }
    formtool_save(field1, save_from);
    formtool_save(field2, save_to);
    if (counter_from) {
        counter_from.value = field1.length;
    }
    if (counter_to) {
        counter_to.value = field2.length;
    }

}

function formtool_copy(field1, field2, save, counter, copyall) {
    if (copyall == true) {
        formtool_add_all(field1, field2, true);
    } else {
        formtool_add_item(field1, field2, true);
    }
    formtool_save(field2, save);
    if (counter) {
        counter.value = field2.length;
    }
}

function formtool_remove(field, save, counter, removeall) {
    if (removeall == true) {
        formtool_remove_all(field);
    } else {
        formtool_remove_item(field);
    }
    formtool_save(field, save);
    if (counter) {
        counter.value = field.length;
    }
}


// code form adding/removing items originated from devx.com by Boris Feldman
// http://gethelp.devx.com/techtips/js_pro/10min/10min0499/10min0499.asp

function formtool_add_item(field1, field2, ignore_duplicates) {
    var i;
    var j;
    var itemexists;
    var nextitem;

    // step through all items in field1
    for (i = 0; i < field1.options.length; i++) {
        if (field1.options[i].selected) {
            // search field2 to see if duplicate
            j = 0;
            itemexists = false;
            while ((j < field2.options.length) && (!(itemexists))) {
                if (field2.options[j].value == field1.options[i].value) {
                    itemexists = true;
                    if (!ignore_duplicates) {
                       alert(field1.options[i].value + " found!");
                    }
                }
                j++;
            }
            if (!(itemexists)) {
                // add the item
                nextitem = field2.options.length;
                field2.options[nextitem] = new Option(field1.options[i].text);
                field2.options[nextitem].value = field1.options[i].value;
            }
        }
    }
}

function formtool_remove_item(field1) {
    var i;
    for (i = 0; i < field1.options.length; i++) {
        if (field1.options[i].selected) {
           field1.options[i] = null;
           i--;
        }
    }
}

function formtool_add_all(field1, field2, ignore_duplicates) {
    var i;
    var j;
    var itemexists;
    var nextitem;

    // step through all items in field1
    for (i = 0; i < field1.options.length; i++) {
        // search field2 to see if duplicate
        j = 0;
        itemexists = false;
        while ((j < field2.options.length) && (!(itemexists))) {
            if (field2.options[j].value == field1.options[i].value) {
                itemexists = true;
            }
            j++;
        }
        if (!(itemexists)) {
            // add the item
            nextitem = field2.options.length;
            field2.options[nextitem] = new Option(field1.options[i].text);
            field2.options[nextitem].value = field1.options[i].value;
        }
    }
}

function formtool_remove_all(field1) {
   field1.options.length = 0;
}

function formtool_set_size(list1, list2){
    list1.size = formtool_get_size(list1);
    list2.size = formtool_get_size(list2);
}

function formtool_unselect_all(list1, list2){
    list1.selectedIndex = -1;
    list2.selectedIndex = -1;
    moved_element = -1;
}

function formtool_get_size(list){
    var moz_len = 0;
    for(i=0; i < list.childNodes.length; i++) {
       if( list.childNodes.item(i).nodeType == 1 ) { moz_len++; }
    }
    if(moz_len < 2)
        return 2;
    else
        return moz_len;
}

function formtool_count_chars(textField,  countField,  maxlen, show_alert) {
    if(textField != null && textField.value != null) {
        if (textField.value.length > maxlen){
            if(show_alert)
               alert('This field cannot exceed ' +  maxlen + ' characters.');
            textField.value = textField.value.substring(0,  maxlen);
        } else {
            countField.value = maxlen - textField.value.length;
        }
    }
}


Other Content Management Scripts:

WebMaster Resources Home

©RingsWorld.com